[postgis-users] Split / Divide linestring into parts / segments ?

Simon Greener simon at spatialdbadvisor.com
Wed Oct 14 00:06:05 PDT 2009


Grant,

Are you after something like this:

SELECT ST_AsText(ST_Line_SubString(the_geom,
                                    ((g::float-1.0) / 30.0),
                                    (g::float/30::float) )) as segment,
        ST_Length(ST_Line_SubString(the_geom,
                                    ((g::float-1.0) / 30.0),
                                    (g::float/30::float) )) as length,
        g as segment_number,
        ((g::float-1.0) / 30.0) as start,
        (g::float/30::float)    as end
   FROM (select ST_GeomFromText('LINESTRING(748130 2919491,747979 2919630,747895 2919705)') as the_geom) as l,
         generate_series(1,30,1) as g;

regards
Simon
On Wed, 14 Oct 2009 17:18:53 +1100, Grant Masan <grant.massan at gmail.com> wrote:

> Hi,
>
> Thanks Regina ! Good case but it is not helping me in my case. So if I can
> make this more clear to everybody I need to divide/split one linestring to
> 30 different pieces. So I can see where other linestrings has intersected
> this one linestring. Like how many linestrings has crossed the "door" in
> section 1 or 3 and so on...
>
>                                linestring "door"
>
> <----1------><-----2-----><------3------><-------5-----><-----6-------> and
> so on ...
>


-- 
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