[postgis-users] GeometryN

Lars Rößiger lars.roessiger at d33.net
Tue Oct 25 04:41:35 PDT 2005

Hi all!

I need to extract specific geometries from a result set. To original
result set looks like this (I stripped the numbers for readability):

SELECT AsText(the_geom) FROM nbg_landuse WHERE gid = 69;

    11.0961296 49.4972128,11.0958999 49.4966784,
    11.095143 49.4960281,11.093623 49.4953756,
    11.0667155 49.4980046,11.0674851 49.4979275,
    11.0703643 49.4976697,11.0705108 49.4977082,
(1 row)

So if I want to extract the first geometry I try this:

SELECT AsText(GeometryN(the_geom, 1))
FROM (SELECT the_geom FROM nbg_landuse WHERE gid = 69) AS foo;

But this doesn't work the way it used to? It returns the exact same data
as shown above except that it reads 'POLYGON' instead of 'MULTIPOLYGON'.

When I try to extract the third geometry...

SELECT AsText(GeometryN(the_geom, 3))
FROM (SELECT the_geom FROM nbg_landuse WHERE gid = 69) AS foo;

... it returns nothing :-(

What do I do wrong? Is this correct behaviour of GeometryN?


More information about the postgis-users mailing list