Hi Rainer,

If your linestrings aren't too large (ie < 1000pts), you can actually do this with a simple query. The reason I say this is because generate_series doesn't scale well.

postgis=# CREATE TEMP TABLE mylines AS
postgis-#   SELECT 'LINESTRING(0 0, 0 1, 1 1, 1 0, 0 0)'::geometry AS geom;
SELECT
postgis=# SELECT AsText( MakeLine(sp,ep) )
postgis-# FROM (
postgis(#   SELECT pointn(geom, generate_series(1, npoints(geom)-1)) as sp,
postgis(#          pointn(geom, generate_series(2, npoints(geom)  )) as ep
postgis(#   FROM mylines ) AS foo;
      astext
---------------------
LINESTRING(0 0,0 1)
LINESTRING(0 1,1 1)
LINESTRING(1 1,1 0)
LINESTRING(1 0,0 0)
(4 rows)

Cheers,
Kevin

-------------
Kevin Neufeld
Software Developer
Refractions Research Inc.
300-1207 Douglas St.
Victoria, B.C., V8W 2E7

Phone: (250) 383-3022
Email: [EMAIL PROTECTED]



Rainer Spittel wrote:
Hello,
I like to split a linestring geometry with several points into a number of 2 point line segments. I want to use those line segments to measure the length of each individual side of a polygon/linestring. Before writing a function which iterate through each point in the input linestring and create a set of 2 point lines, is there a better way of archiving the same result? Cheers
Rainer
------------------------------------------------------------------------

_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to