The goal is to divide a raster file into quadrants in order to make some computation in each. I'd like to split the raster and create a raster brick with those parts. I don't need to get perfect clips of the raster so the cell with data in the border of the clip could be also present in the contiguous raster brick.
I'm thinking about creating a radial grid and then extract the raster by masking it with each of the polygons within. I found these interesting questions about the topic.
How can be done this in R ?
Here you have the layer (dem) to tryout.
- Note 1: number of quadrants must be a parameter.
- Note 2: raster brick must have same extension as the original raster.
- Note 3: process must be done in R (a function would be perfect)
Update 10/06/2020: I hope this schema clarifies the purpose: A Function that given a raster and a number of sectors it creates a raster brick (with number of rasters = number of sectors) where each raster keeps just the values within the correspondent sector.
(0,0)->(xmax,0)->(xmax,ymax)
) so you can define these polygons in eight very short lines. Have you tried?c(sin(k*2*pi/8)*width,0,sin((k+1)*2*pi/8)*width)
y:c(cos(k*2*pi/8)*width,0,cos((k+1)*2*pi/8)*width)
, k ranges from 0 to 7, width is raster width. Those polygons will be surely bigger than needed, but must work just fine.