R:根据坐标将对应ID的多边形分配给shapefile中的点
R: Assign corresponding ID's polygon to points in shapefile according to coordinates
我有两个 shapefile。第一个是区域的多边形形状文件,每个区域都有一个唯一的 ID。第二个是点 shapefile,事件发生在 shapefile1 的区域。
我想为点 shapefile 的每个事件(行)分配多边形 shapefile 的相应区域 ID。
关于如何使用 R 执行此操作的任何想法?
提前致谢。
为此你应该可以使用 over()
。
Points_w_Region <- over(points,regions) ## Get the information
Points$regions <- Points_w_Region ## Assign the information to the data
这会将通过 over 获得的区域分配给每个点。
over()
是 sp 包的一部分,我假设您的数据在 sp 结构中。
我有两个 shapefile。第一个是区域的多边形形状文件,每个区域都有一个唯一的 ID。第二个是点 shapefile,事件发生在 shapefile1 的区域。
我想为点 shapefile 的每个事件(行)分配多边形 shapefile 的相应区域 ID。
关于如何使用 R 执行此操作的任何想法?
提前致谢。
为此你应该可以使用 over()
。
Points_w_Region <- over(points,regions) ## Get the information
Points$regions <- Points_w_Region ## Assign the information to the data
这会将通过 over 获得的区域分配给每个点。
over()
是 sp 包的一部分,我假设您的数据在 sp 结构中。