简体   繁体   中英

How do I delete factor levels in a spatialpolygonsdataframe in R?

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.

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

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