[postgis-users] Why doesn't startpoint work? (and X() for that matter)

Ethan Alpert ealpert at digitalglobe.com
Tue Dec 28 05:37:30 PST 2004

Ok got it. I think the documentation should be changed from "find an return the X coordinate of the first point in the geometry" to "...first point in a linestring"


From: strk at refractions.net [mailto:strk at refractions.net]
Sent: Tue 12/28/2004 2:16 AM
To: Ethan Alpert
Cc: PostGIS Users Discussion
Subject: Re: [postgis-users] Why doesn't startpoint work? (and X() for that matter)

On Mon, Dec 27, 2004 at 05:14:51PM -0700, Ethan Alpert wrote:
> >From the docs:
> X(geometry)
> Find and return the X coordinate of the first point in the geometry.
> Return NULL if there is no point in the geometry.
> StartPoint(geometry)
> Returns the first point of the geometry as a point.
> spatialdb=> select startpoint(the_geom),X(the_geom),the_geom from snaps
> where catalogid ='101001000379CE01';
> -[ RECORD 1]
> startpoint |
> x          |
> the_geom   | SRID=4326;POLYGON((73.2565444444444
> 45.141725,73.4717277777778 45.1421555555556,73.4707527777778
> 44.9756666666667,73.257175 44.975625,73.2565444444444 45.141725))
> So what gives?! Why do these return NULL? Is there a better reference
> doc somewhere?

These are OGC functions. StartPoint/EndPoint should only work with
LineString inputs (postgis actually extends this looking for the
first LineString in a complex geometry, but that 'extension' should
probably be dropped for OGC *strictness*). X/Y/Z/M should only
work with Point geometries.

Your query should be:

=> SELECT StartPoint(OuterRing(the_geom)), X(StartPoint(OuterRing(the_geom)))
   FROM snaps WHERE catalogid = '101001000379CE01';

> While we're on the subject how can I convert between geometry types? I'd
> like to turn some polygons into lines.

There is no function available for this. You should script it
with calls to ExteriorRing(), NumInteriorRing() and InteriorRingN().


> -e
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20041228/f0371ec1/attachment.html>

More information about the postgis-users mailing list