简体   繁体   中英

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. 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. I think I can do that by using the tapply function (with "sum"), but I need to create the grid first. any suggestions? Thank you

Try to use the polygrid function. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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