[R-sig-Geo] Order a SpatialPolygonsDataFrame by a column: area

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon Apr 4 18:52:43 CEST 2011



On 04/04/2011 05:47 PM, Mathieu Rajerison wrote:
> Hi List!
> 
> I've got a Spatial Polygons Data Frame and have calculated the area of the
> polygons (area column)
> 
> I wondered how I could now order my features by area with small features on
> the top..

If you mean by "on the top" as "from first to last", then try

x[order(x$area),]

If you mean by "on the top", being plotted later than any other, you
might want the reverse ordering:

x[rev(order(x$area)),]

?
> 
> Any idea?
> 
> Thanks,
> 
> Mathieu
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list