Hi, The new st_dumppoints() function may be useful in your case. It returns an array of (path, point) that represents the line vertices:
select st_dumppoints('LINESTRING(0 0, 1 1, 2 2)'::geometry); st_dumppoints -------------------------------------------------- ({1},010100000000000000000000000000000000000000) ({2},0101000000000000000000F03F000000000000F03F) ({3},010100000000000000000000400000000000000040) (3 rows) Nicolas On 9 February 2012 21:57, Stephen V. Mather <s...@clevelandmetroparks.com>wrote: > Hi All,**** > > If I’m converting from a line to its vertices, I use > something like this (ala the postgis docs):**** > > ** ** > > SELECT **** > > ST_PointN(**** > > the_geom,**** > > generate_series(1, ST_NPoints(the_geom))**** > > )**** > > FROM ms_trails_test AS foo;**** > > ** ** > > Now, if I want to make sure I keep all those vertices in order for later, > I better give them an id, so here’s my original cludge:**** > > ** ** > > SELECT **** > > ST_PointN(**** > > the_geom,**** > > generate_series(1, ST_NPoints(the_geom))**** > > ),**** > > generate_series(1, ST_NPoints(the_geom)) + foo.gid * 100000 > **** > > FROM ms_trails_test AS foo;**** > > ** ** > > Which is fine for most cases, but not really a general solution… .**** > > Better yet, I’ll just keep my original gid as the feature id and have a > separate vertex id:**** > > ** ** > > SELECT **** > > ST_PointN(**** > > the_geom,**** > > generate_series(1, ST_NPoints(the_geom))**** > > ),**** > > gid as feature_id,**** > > generate_series(1, ST_NPoints(the_geom)) as vertex_id**** > > FROM ms_trails_test AS foo;**** > > ** ** > > Thus, I can play with the points and reassemble them back into lines > later. But, it seems inefficient to run generate_series twice. Is this > the best way?**** > > ** ** > > ** ** > > ** ** > > ** ** > > ** ** > > **[image: http://www.clemetparks.com/images/esig/cmp-ms-90x122.png]**Stephen > Mather > Geographic Information Systems (GIS) Manager > (216) 635-3243**** > > s...@clevelandmetroparks.com > clevelandmetroparks.com <http://www.clemetparks.com/>**** > > ** ** > > ** ** > > ** ** > > ** ** > > _______________________________________________ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users > >
<<image001.png>>
_______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users