Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splitting a geo polygon into multiple polygons of specific area

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.

like image 501
r_noob Avatar asked Jan 29 '26 21:01

r_noob


1 Answers

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).

like image 134
Gilles Avatar answered Feb 01 '26 14:02

Gilles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!