[postgis-users] how can I end points

Patrick Valsecchi patrick.valsecchi at camptocamp.com
Mon Sep 17 03:22:44 PDT 2007


Hi,

You have st_startpoint(geom) and st_endpoint(geom) to get your two points. But 
st_endpoint is broken in PostGIS 1.3.1. So you can replace it with 
st_pointn(geom, st_numpoints(geom)).

To compute the distance between those two point, I think you can use something 
like st_distance(geom1, geom2).

So we have, for example:
select st_distance(st_startpoint(geom), st_endpoint(geom)), st_length(geom) 
from table;

Or:
select st_distance(st_startpoint(geom), st_pointn(geom, st_numpoints(geom))), 
st_length(geom) from table;

Anyway, you have all that in the doc:
http://postgis.refractions.net/docs/ch06.html

CU

On Monday 17 September 2007, temiz wrote:
> hello
>
> I want to calculate the distance between two end points of a linestring.
>
> LINESTRING( x1 y1,x2 y2,x3 y3, x4 y4)
>
> something like direct distance between (x1 y1) and (x4 y4)
>
> how can I end points of a line ?
>
>
> regards



More information about the postgis-users mailing list