Simple way to subset SpatialPolygonsDataFrame (i.e. delete polygons) by attribute in R

后端 未结 5 614
星月不相逢
星月不相逢 2020-12-04 11:54

I would like simply delete some polygons from a SpatialPolygonsDataFrame object based on corresponding attribute values in the @data data frame so that I can plot a simplifi

5条回答
  •  时光说笑
    2020-12-04 12:28

    looks like you're overwriting the data, but not removing the polygons. If you want to cut down the dataset including both data and polygons, try e.g.

    world.map <- world.map[world.map$AREA > 30000,]
    plot(world.map)
    

    [[Edit 19 April, 2016]] That solution used to work, but @Bonnie reports otherwise for a newer R version (though perhaps the data has changed too?): world.map <- world.map[world.map@data$AREA > 30000, ] Upvote @Bonnie's answer if that helped.

提交回复
热议问题