I hope to incorporate raster::focal() as a method for more flexible function and weight specifications. When time allows, I'll continue working to generalize this function for use on rasters with non-square cells. For aggregating densities, means, and other higher-moment measures, pass a function to the fun parameter. Aggregation groups rectangular areas to create larger cells. (a) raster aggregated to g 5 (b) aggregated g 5 from publication: Effect of. This default is appropriate for rasters modeling zeroth-moment measures, like population counts and coverage area. Aggregate a SpatRaster to create a new SpatRaster with a lower resolution (larger cells). Download scientific diagram Aggregation and interpolation of raster (f). The default function used in aggregation is a weighted sum that assumes an even distribution of units within raster cells. DescriptionĬurrently, the function works by resampling the raster input to a higher resolution and aggregating this intermediate. The main file is a generalized form of the solution to a Stack Overflow question on how to circumvent raster::aggregate()'s requirement for an integer-value aggregation factor.Ĭorrections and suggestions for either file would be greatly appreciated. # Need to figure out how to aggregate properly with focal(). If(ncol( wts) %% 2 = 0) wts <- cbind( wts, 0) Using aggregate in R is very simple and it is worth to mention that you can apply any function you want, even a custom function. Wts + 1) : dim_new, ] <- dwnscl * wts + 1) : dim_new, ] Wts + 1) : dim_new] <- dwnscl * wts + 1) : dim_new] # but note that this uniform down-scaling assumes an even distribution of units within each cell # this assigns weights equal to the increase in cell size, # leave these weights as 1 while scaling all others down according to aggregation factor # next, find the original raster cells in the high-res raster Wts <- matrix( 1, ncol = dim_new, nrow = dim_new) ![]() # find dimensions of matrix outlining all values to be included in aggregation # high-res cells located in the original raster get a weight of 1 Hi I am using your rasteraggnonint.r script to aggregate a large raster and it is amazing, thank you However, my script is taking ages to run and I was. ![]() ![]() Tmp2 <- raster(extent( r), crs = crs( r), resolution = tres2) Hi_res <- projectRaster( r, to = tmp1, method = proj_method) Tmp1 <- raster(extent( r), crs = crs( r), resolution = tres) # resample to high resolution as intemediate step R <- raster( resolution = c( 1, 2), nrow = 100, crs = proj) Proj <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs " # Attempting to make more flexible with focal function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |