[postgis-users] How to get n largest (multi-)polygons contained in parent (multi-)polygon?

Sandro Santilli strk at keybit.net
Mon Jul 25 02:27:42 PDT 2011


On Mon, Jul 25, 2011 at 01:15:08AM -0700, Scholle wrote:

> How to get n largest (multi-)polygons
> contained in parent (multi-)polygon?

WITH dump AS ( SELECT (ST_Dump(parent)).* ) 
SELECT * FROM dump
  ORDER BY ST_Area(geom)
  LIMIT n;

You can play with st_collect/group by if you want to limit
the dump to a specific sublevel of the collection.

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html



More information about the postgis-users mailing list