0

I have files from ERA5 that have extent from 0 to 360 (lon) and -90 to 90 (lat)

Example:

> era5_sr
class       : SpatRaster 
dimensions  : 721, 1440, 744  (nrow, ncol, nlyr)
resolution  : 0.25, 0.25  (x, y)
extent      : -0.125, 359.875, -90.125, 90.125  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs 
source      : ssrd.hh.fc.era5.01.2018.nc 
varname     : ssrd (Surface solar radiation downwards) 
names       :  ssrd_1,  ssrd_2,  ssrd_3,  ssrd_4,  ssrd_5,  ssrd_6, ... 
unit        : J m**-2, J m**-2, J m**-2, J m**-2, J m**-2, J m**-2, ... 
time        : 2018-01-01 to 2018-01-31 23:00:00 UTC 

Is there a way to modify the dimensions from -180 to 180 (lon) using tidy / dplyr ? I know that terra we can do it easily through another raster of the desired extent but I need to find a way through tidy.

2
  • There is tidyterra whose note or performance says, in part, When manipulating large raster files (i.e. more than 10.000.000 cells), it is recommended to use the native terra syntax, that is specifically designed for handling this type of files. 721*1440*744 would seem to drift outside of tidyterra's use case.
    – Chris
    Commented Jul 1 at 15:43
  • Thank you !! Never heard aboot it ! How would you use it ? I am working with longitudinal slices. It should o the trick :) Commented Jul 1 at 16:06

1 Answer 1

3

The easy approach with terra is not to do what you suggest, but rather do

x <- terra::rotate(era5_sr)

This is a very particular operation. I do not think there is an alterative that is more tidy.

4
  • Yes, I know thank you. However, I am working on a model and the data is transformed to dataframe from the beginning. So I need to use tidyr/dplyr formatting. Commented Jul 2 at 8:58
  • 1
    Then you could change your workflow (first rotate, then make a data.frame? Or explain in your question that you have a data.frame and not a SpatRaster... Commented Jul 2 at 15:16
  • Thanks! In the question, it's already mentioned that I have a spat raster... class : SpatRaster Commented Jul 5 at 17:05
  • You contradict yourself in the comment above where you say that you have a data.frame that you want to transform. Commented Jul 6 at 13:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.