简体   繁体   English

在R中的不规则多边形内生成规则网格

[英]generating regular grid inside irregular polygon in R

I have an irregular polygon (an area of the Pacific Ocean off Mexico), and I would like to create a regular grid (say 1/2° x 1/2°) inside that polygon. 我有一个不规则的多边形(墨西哥以外的太平洋区域),我想在该多边形内创建一个规则的网格(例如1/2°x 1/2°)。 I have some points inside that polygon, and I would like to add all the points that lie inside those 1/2° x 1/2° squares. 我在该多边形内有一些点,我想添加位于这些1/2°x 1/2°正方形内的所有点。 I think I can do that by using the tapply function (with "sum"), but I need to create the grid first. 我想我可以通过使用tapply函数(带有“ sum”)来做到这一点,但是我需要首先创建网格。 any suggestions? 有什么建议么? Thank you 谢谢

Try to use the polygrid function. 尝试使用polygrid函数。 This function is in the geoR package and it basically creates a grid in a rectangle and extracts only the points that are inside your polygon. 此函数在geoR软件包中,它基本上在矩形中创建网格,并且仅提取多边形内部的点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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