[postgis-users] Find individual lengths of a line between vertices

benton101 Ben.Davies at dec.wa.gov.au
Mon May 11 19:15:58 PDT 2009


Hi,

I have a line of Geo Type LINESTRING. It contains one vertices somewhere
along its total length with a start and end point. I want to find the length
of each line between the end points and the vertices. I have attempted to
use ST_Dump to do this. I was hoping that it would create two records, but
it seems that ST_Dump see's it as one geometry. Is this true and if so is
there another function I could use to find out the length of each vertices?

This is the sql I have formed, the table has some lines that overlap /
intersect each other ...

SELECT get_results.the_geom AS the_geom
  FROM (SELECT (ST_Dump(dump_results.the_geom)).geom AS the_geom
          FROM (SELECT ST_MakeLine(union_results.pnt) AS the_geom
                     , union_results.gid AS gid
                  FROM (SELECT a.gid
                             , ST_StartPoint(ST_Intersection(a.the_geom,
b.the_geom)) AS pnt
                          FROM spl_mga_road_lines a
                             , spl_mga_road_lines b
                         WHERE ST_Intersects(a.the_geom,b.the_geom)
                           AND
GeometryType(ST_StartPoint(ST_Intersection(a.the_geom, b.the_geom))) =
'POINT'
                               UNION
                        SELECT a.gid
                             , ST_Intersection(a.the_geom, b.the_geom) AS
pnt
                          FROM spl_mga_road_lines a
                             , spl_mga_road_lines b
                         WHERE ST_Intersects(a.the_geom,b.the_geom)
                           AND GeometryType(ST_Intersection(a.the_geom,
b.the_geom)) = 'POINT'
                               UNION
                        SELECT a.gid
                             , ST_EndPoint(ST_Intersection(a.the_geom,
b.the_geom)) AS pnt
                          FROM spl_mga_road_lines a
                             , spl_mga_road_lines b
                         WHERE ST_Intersects(a.the_geom,b.the_geom)
                           AND
GeometryType(ST_EndPoint(ST_Intersection(a.the_geom, b.the_geom))) = 'POINT'
                             ) union_results
              GROUP BY union_results.gid) dump_results
WHERE ST_Length(dump_results.the_geom) > 5.0)get_results


Thank You
Ben

-- 
View this message in context: http://www.nabble.com/Find-individual-lengths-of-a-line-between-vertices-tp23494997p23494997.html
Sent from the PostGIS - User mailing list archive at Nabble.com.




More information about the postgis-users mailing list