I have a shapefile which is the national boundary line of Chile. If possible, I would like to randomly generate e.g. 1000 polygons within this area. I'm wondering what the best way would be to go about this in R? I thought maybe, loading the shapefile using the 'shapefiles' package, then creating a point dataset using something available in 'spatstat'. Then I could create circular polygons based around these points... This is mostly hypothetical and I don't know if its possible.
I have some experience in R but haven't really tried any spatial analysis before.
Any thoughts and suggestions would be appreciated.
Could you work with raster polygons?
Generate a fine grid (less than your target polygon area) over your shapefile polygon, then pick a random 'seed' grid square and 'grow' it by adding nearest grid cells incrementally, until it is the size you want. This way you'll get approximately circular polygons inland, and semi-circular polygons if you start with a coastal cell.
Whether a raster representation is okay for you depends on what you plan to do when you have created these polygons, but it looks like you are just going to overlay them on other land use data, which can be done with rasters on rasters or rasters on polygons.
Should all be doable within the raster package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With