[R-sig-Geo] How to remove polygons according to their attributes?

Oehler, Friderike (AGPP) Friderike.Oehler at fao.org
Fri Sep 5 11:16:21 CEST 2008


Hi Lin,

I think you can simply do your selection as with any dataframe, e.g.

require(rgdal)
Ctries=readOGR(dsn='C:/data/datasets/HornOfAfrica', layer='HornOfAfrica',
p4s=NULL)
str(Ctries at data)
try<-Ctries[Ctries$AREA>100,]
spplot(try, zcol='ADM0_CODE')
# or:
Kenya<-Ctries[Ctries$ADM0_NAME=='Kenya',]
spplot(Ctries, zcol='ADM0_CODE',sp.layout=list(list("sp.polygons",Kenya,
col="red")), scales=list(draw=TRUE), xlim=c(30,52), ylim=c(-10,18),
col.regions='transparent', colorkey=FALSE)

Hope this helps,
Friderike


-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Xin LIN
Sent: 05 September 2008 10:07
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] How to remove polygons according to their attributes?


Hi, everyone

I have a shapefile with many adjacent polygons in. Each has a series of
attributes such as ID and area. Now I want to remove some of them based on
attributes, e.g. to remove polygons with areas less than a given value. How
can I proceed?

Thanks a lot.=)

Lin Xin

-- 
Lin Xin
Department of Ecology,
College of Urban and Environmental Sciences
Peking University
Beijing 100871, China
Tel: +8610 62765578
Mobile: +86 15801416516
Email: linxin.pku at gmail.com

	[[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo




More information about the R-sig-Geo mailing list