[postgis-users] Keeping vertices from lines in order... .

Stephen V. Mather svm at clevelandmetroparks.com
Thu Feb 9 14:00:51 PST 2012


Ah, and I see it's a 1.5 feature.  Thank you.

 

Steve

 

http://www.clemetparks.com/images/esig/cmp-ms-90x122.pngStephen Mather
Geographic Information Systems (GIS) Manager
(216) 635-3243

svm at clevelandmetroparks.com
 <http://www.clemetparks.com/> clevelandmetroparks.com

 

 

 

 

From: nicky666 at gmail.com [mailto:nicky666 at gmail.com] On Behalf Of Nicolas
Ribot
Sent: Thursday, February 09, 2012 4:40 PM
To: svm at clevelandmetroparks.com; PostGIS Users Discussion
Subject: Re: [postgis-users] Keeping vertices from lines in order... .

 

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 <svm at 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?

 

 

 

 

 

http://www.clemetparks.com/images/esig/cmp-ms-90x122.pngStephen Mather
Geographic Information Systems (GIS) Manager
(216) <tel:%28216%29%20635-3243>  635-3243

svm at clevelandmetroparks.com
 <http://www.clemetparks.com/> clevelandmetroparks.com

 

 

 

 


_______________________________________________
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/20120209/2538e16b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 3772 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120209/2538e16b/attachment.png>


More information about the postgis-users mailing list