我有一组坐标作为R中的SpatialPointsDataFrame对象,我使用多边形剪切这些点,只获取在此多边形内找到的那些点.我使用rgeos包中的gIntersection函数执行此操作.我的问题是该函数只返回这些点的坐标,而不是与它们相关的元数据.有没有办法让gIntersection将所有数据传递给结果,而不仅仅是坐标?
这是一个例子:
SpatialPointsDataFrame表示物种出现点:
> spexample
coordinates SpAbbr InstitutionCode CatalogNumberText
1 (-76.8727, 3.66282) BanRot EBIRD_COL OBS81997559
2 (-76.9749, 3.71683) BanRot AUDCLO OBS89767945
3 (-76.884, 3.61609) BanRot AUDCLO OBS89769896
4 (-77.5167, 5.51667) BanRot AMNH Skin-123476
5 (-76.0334, 4.86669) BanRot LACM 34848
6 (-78.4333, 1.43333) BanRot LSUMZ 38939
7 (-78.55, 0.95) BanRot ANSP 182799
8 (-79.2139, 0.471944) BanRot AUDCLO OBS58485973
9 (-78.5104, 0.895349) BanRot AUDCLO OBS84822747
10 (-78.3781, 1.51028) BanRot AUDCLO OBS67916517
11 (-75.15, 7.07) BanRot 8110002317-09 4743-5160
Run Code Online (Sandbox Code Playgroud)
将这些点剪切为多边形:
> gIntersection(spexample,bufferclip)
SpatialPoints:
x …Run Code Online (Sandbox Code Playgroud)