在 R 中设置的 shapefile 边界内创建随机多边形 [英] Creating random polygons within a set shapefiles boundary in R

查看:54
本文介绍了在 R 中设置的 shapefile 边界内创建随机多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个形状文件,它是智利的国界线.如果可能,我想随机生成例如该区域内有 1000 个多边形.我想知道在 R 中最好的方法是什么?我想也许,使用shapefiles"包加载shapefile,然后使用spatstat"中可用的东西创建一个点数据集.然后我可以基于这些点创建圆形多边形......这主要是假设,我不知道是否可能.

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.

我在 R 方面有一些经验,但之前还没有真正尝试过任何空间分析.

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?

在您的 shapefile 多边形上生成一个精细网格(小于您的目标多边形区域),然后选择一个随机的种子"网格方块并通过逐渐添加最近的网格单元来增长"它,直到它成为您想要的大小.这样,如果您从沿海单元开始,您将获得大约圆形的内陆多边形和半圆形多边形.

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.

这篇关于在 R 中设置的 shapefile 边界内创建随机多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆