![]() ![]() # and FINER (smaller cells) resolutions, respectivelyĬoarseResampRaster <- aggregate(inputRaster,fact=resampleFactor,fun=mean) # The aggregate() / disaggregate methods resample rasters to COARSER (bigger cells) Message(sprintf("resampling file: %s",inFiles)) # Note: these images do not have same spatial extent, so they cant be stored # Within the same loop, obtain the (geographic) extent of each component. # Read the mosaic components, stored in a subfolder, into a raster object list. ResampleFactor <- 4 # For test, subsample incoming image by factor of 10 # spatial resolution using the R raster package. # This function demonstrates resampling of raster images to a new This would normally be a SpatRaster that you already have from another data source. Therefore, the preferred approach is to provide a template to which you want the output to align with. You can do that like this: u1 <- project(r, "+proj=utm +zone=32")īut, unlike for vector data, the transformation of raster data is not well-defined. It could also be that you want to transform raster data to a geometry with another coordinate reference system ("map projection"). In that case you can use resampleĮxample of a non-aligned SpatRaster: x <- rast(r) But to combine raster data from different sources, you may need to match the geometry of a raster that does not align. You can also go the other way and disaggregate: d <- disagg(a2, 2)Īggregate can only combine entire cells. You can use a different factor for the rows and columns, and also different aggregation functions (the default is "mean") a2 <- aggregate(r, c(2,3), fun=sum) ![]() To go from 30 to 120m is a factor of 4 a1 <- aggregate(r, 4) These days we can use terra, the replacement for the raster packageį <- system.file("ex/elev.tif", package="terra")Īggregate raster cells. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |