Re: How to use function PointN?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Nemo Terry <ntuser155(at)hotmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to use function PointN?
Date: 2007-05-07 13:13:43
Message-ID: 20070507131343.GA90126@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, May 07, 2007 at 04:07:00PM +0800, Nemo Terry wrote:
> select PointN(envelope(polyline),1) from highway;
> return null,why?

PointN is a PostGIS function; you might get more help on the
postgis-users mailing list.

http://postgis.refractions.net/mailman/listinfo/postgis-users

See also the PostGIS documentation for Envelope and PointN:

http://postgis.refractions.net/docs/ch06.html

Envelope(geometry)

Returns a POLYGON representing the bounding box of the geometry.

PointN(geometry,integer)

Return the N'th point in the first linestring in the geometry.
Return NULL if there is no linestring in the geometry.

You've used Envelope to get a polygon but PointN expects a linestring.
Try using ExteriorRing on Envelope's polygon:

SELECT PointN(ExteriorRing(Envelope(polyline)), 1) FROM highway;

--
Michael Fuhr

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2007-05-07 14:37:59 Re: Sequence vs. Index Scan
Previous Message Andrew Sullivan 2007-05-07 10:58:29 Re: Sequence vs. Index Scan