Ho un set di coordinate come oggetto SpatialPointsDataFrame in R e sto tagliando questi punti utilizzando un poligono per ottenere solo quei punti che si trovano all'interno di questo poligono. Lo sto facendo con la funzione gIntersection dal pacchetto rgeos. Il mio problema è che la funzione restituisce solo le coordinate di quei punti e non i metadati ad essi associati. C'è un modo per fare in modo che gIntersection passi tutti i dati al risultato, anziché solo le coordinate?Mantenere i metadati quando si utilizza gIntersection dal pacchetto rgeos in R
Ecco un esempio:
I SpatialPointsDataFrame rappresentano specie punti occorrenza:
> 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
Clipping quei punti ad un poligono:
> gIntersection(spexample,bufferclip)
SpatialPoints:
x y
1 -78.55000 0.9500000
1 -78.51036 0.8953493
1 -78.43333 1.4333333
1 -78.37810 1.5102800
1 -76.97495 3.7168289
1 -76.88397 3.6160872
1 -76.87271 3.6628163
1 -76.03337 4.8666900
Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84
+ellps=WGS84 +towgs84=0,0,0
Grazie per il suggerimento! È un ottimo modo per aggirare. – Pascal