[英]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. 我有一个SpatialPolygonsDataFrame,其中$ Species是一个因子变量,并具有22个级别的猎物。 I would like R to only consider 16 of these species and delete the other 6. 我希望R仅考虑这些物种中的16种,而删除其他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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.