Reputation: 33
I am trying to split a polygon on R into multiple polygons of equal areas.
I have the boundaries of the polygon which I need to split in boxes measuring 1km by 1km using R. I was wondering if this is possible using R.
For example:
x <- extent(c(40.97453103, 41.06321504, -92.47427103, -92.36617044))
plot(x)
This creates a box with the given bounds. I am trying to create multiple boxes within the bounds of size 1km by 1km and then merge it on google maps using ggmap.
Upvotes: 3
Views: 2683
Reputation: 4370
You can use the st_make_grid
function from the sf
package but we don't know your coordinates reference system and the units used.
Here is an example with grids of an arbitrary size :
library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.1.3, proj.4 4.9.2
x <- cbind(c(40.97453103, 41.06321504, 41.06321504, 40.97453103, 40.97453103),
c(-92.47427103, -92.47427103, -92.36617044, -92.36617044, -92.47427103))
x <- st_sf(st_sfc(st_polygon(list(x))))
grid <- st_make_grid(x, cellsize = c(0.01,0.01))
par(mar = c(1,1,1,1))
plot(x)
plot(grid, add = T)
Created on 2018-02-25 by the reprex package (v0.2.0).
Upvotes: 4