简体   繁体   中英

Divide bounding box / extent into several parts in R

I have an extent which is shown below. The extent is in the form of a square and I would like to split the whole extent into several small squares so that I can process each small extent (square) individually. Could anyone help me with this?

require(raster)    
x <- extent(c(5.956135, 10.47513, 45.817936, 47.808453))

Since I found the answer by myself I am posting the answer.

x <- seq(1:4)
df <- data.frame(x)
xFactor <- (47.808453 - 45.817936)/length(x)
yFactor <- (10.47513 - 5.956135)/length(x)
df$xCH <- df$x*xFactor + 47.808453
df$yCH <- -df$x*yFactor + 10.47513

Coordinates for the split extent can be found from the output dataframe very easily.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM