0

This is my raster properties:

class      : RasterLayer 
dimensions : 3001, 3000, 9003000  (nrow, ncol, ncell)
resolution : 0.12, 0.034  (x, y)
extent     : -180, 180, -40.034, 62  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs 
source     : test.tif 
names      : test

I want to convert this into a raster with a resolution of 0.008333333 in both x and y direction

library(raster)
tar_res <- 0.008333333
disagg_raster <- disaggregate(my_raster, 
                              fact = c(res(my_raster)[1]/tar_res, res(my_raster)[2]/tar_res))

disagg_raster
class      : RasterLayer 
dimensions : 12004, 42000, 504168000  (nrow, ncol, ncell)
resolution : 0.008571429, 0.0085  (x, y)
extent     : -180, 180, -40.034, 62  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs 

How do I get the resolution to be 0.008333333 in both x and y direction?

89_Simple
  • 3,393
  • 3
  • 39
  • 94
  • Think you would want to resample [bilinear](https://gis.stackexchange.com/questions/255150/using-resample-vs-aggregate-extend-in-r-to-have-rasters-of-matching-resolutio). – Chris Apr 19 '22 at 12:53

1 Answers1

0

If you cannot get there by (dis) aggregating you can use resample instead.

# example data 
library(terra)
r <- rast(nrow=3001, ncol=3000, ymin=-40.034, ymax=62)

# create empty template with the desired geometry
tmp <- rast(r)
res(tmp) <- 1/120
ymax(tmp) <- ymax(r)

# resample
x <- resample(r, tmp)

See here for a more general and longer answer.

Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63