[postgis-users] segmenting a linestring geometry

Simon Greener simon at spatialdbadvisor.com
Mon Apr 2 16:00:13 PDT 2012


You could do the ST_Segmentize and then use my GetVector function to explode the line at those points.

http://www.spatialdbadvisor.com/postgis_tips_tricks/128/exploding-a-linestring-or-polygon-into-individual-vectors-in-postgis

The only thing is that ST_Segmentize may introduce shorter vectors around the existing vertices as in the following example:

select ST_Distance(ST_MakePoint((vect.*).startcoord.x,(vect.*).startcoord.y),
                    ST_MakePoint((vect.*).endcoord.x,(vect.*).endcoord.y))
   from ST_GetVector(ST_Segmentize('LINESTRING(0 0, 1 1, 2 2, 3 3)'::geometry,0.25)) as vect;

st_distance
double precision
----------------
0.25
0.25
0.25
0.25
0.25
0.164213562373095
0.25
0.25
0.25
0.25
0.25
0.164213562373094
0.25
0.25
0.25
0.25
0.25
0.164213562373094

HTH

regards
Simon

On Tue, 03 Apr 2012 03:38:02 +1000, Ed Linde <edolinde at gmail.com> wrote:

> Hi All,
> I see that ST_Segmentize allows me to introduce points to a line string "x" meters apart. I was wondering ifthere was a way to break the line string so that I can get lines "x" meters in length returned as separate rows..
> all belonging to the one segment ID?
>
> Cheers,
> Ed
>



-- 
Holder of "2011 Oracle Spatial Excellence Award for Education and Research."
SpatialDB Advice and Design, Solutions Architecture and Programming,
Oracle Database 10g Administrator Certified Associate; Oracle Database 10g SQL Certified Professional
Oracle Spatial, SQL Server, PostGIS, MySQL, ArcSDE, Manifold GIS, FME, Radius Topology and Studio Specialist.
39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.
Website: www.spatialdbadvisor.com
   Email: simon at spatialdbadvisor.com
   Voice: +61 362 396397
Mobile: +61 418 396391
Skype: sggreener
Longitude: 147.20515 (147° 12' 18" E)
Latitude: -43.01530 (43° 00' 55" S)
GeoHash: r22em9r98wg
NAC:W80CK 7SWP3



More information about the postgis-users mailing list