0

I have a SpatialPolygonsDataFrame with $Species as a factor variable and with 22 levels of prey species. I would like R to only consider 16 of these species and delete the other 6.

Any suggestions? Nothing on Stack Overflow has worked.

rene
  • 41,474
  • 78
  • 114
  • 152
  • 7
    Could you please tell us what you have tried so far? – Gilles Heinesch Aug 05 '18 at 13:04
  • 1
    There are many ways to subset a SPDF. Have a look [here](https://stackoverflow.com/questions/13443372/simple-way-to-subset-spatialpolygonsdataframe-i-e-delete-polygons-by-attribut) and [here](https://cran.r-project.org/web/packages/spdplyr/vignettes/spdplyr.html) – Steven Beaupré Aug 05 '18 at 13:25

1 Answers1

0

I don't know if this will solve your problem but you can access the coordinates of a spacial polygon object by indexing it. So you extract the coordinates from the species you need and work with that.

map2 = readOGR(dsn = "path", "35MUE250GC_SIR")

coords.sp = map2@polygons[[i]]@Polygons[[1]]@coords #replace i for index
Fino
  • 1,774
  • 11
  • 21