[postgis-users] Splitting/merging linework into equal interval linestrings
pcreso at pcreso.com
pcreso at pcreso.com
Wed Jul 9 21:12:59 PDT 2008
--- On Thu, 7/10/08, Dane Blakely Springmeyer <blake at hailmail.net> wrote:
> From: Dane Blakely Springmeyer <blake at hailmail.net>
> Subject: [postgis-users] Splitting/merging linework into equal interval linestrings
> To: postgis-users at postgis.refractions.net
> Date: Thursday, July 10, 2008, 3:24 PM
> PostGIS users,
>
> I have 1:24k hydrographic linework that I need process in
> several
> successive steps using a postgis workflow.
>
> I'm stuck at step 2 of this overall workflow:
>
> 1) separate all linestrings into distinct Strahler Order
> groups (done)
> 2) split all linework into linestrings of 500 ft (while
> avoiding any
> linestring fragments smaller than 500 ft)
Hi Dane,
I'd look at a script to loop through each line, & generate the segements as percentages of the line. Assuming all lines are not exact multiples of 500ft, you will either need to drop any shortfall (maybe work out from the centre of each line) at one or each end, or if the last segement is < 500ft, do not split it from the line. Or perhaps generate segments of the smallest size > 500ft to fully represent the original line.
in pseudo code, for even segment sizes:
while read line ; do
get line length
if length > 500ft ; then
divide length by 500 & round down to get no of segments
for counter = 1 to no segemnts
ST_Line_substring to generate new segment from counter% to (counter+1)%
of line
fi
done
A similar approach would work for other ways of splitting the lines depending on just how you need to do this. Shell scripts, Perl or Python could all do this. I imagine a custom PostGIS function in plpgsql could also do this, but I think a scripted approach is likely to be more flexible & simpler to write. For me anyway :-)
> 3) perform an elevation lookup to raster data to calculate
> the gradient
> of each 500 ft segment
> and..
> 4) combine all adjacent linestrings which fall into similar
> gradient
> classes.
>
> For step 2 I'm investigating using ST_Segmentize()
> and/or
> ST_Line_substring(), but I'd really appreciate some
> help with how to
> best approach the problem.
>
> ST_Segmentize seems to only insert more nodes/points into
> already very
> high resolution linework (ie nodes already exist at
> intervals much more
> frequent than 500ft), thus extracting linestrings from the
> result of
> ST_Segmentize clearly isn't as simple as using
> MakeLine() between each
> segment.
>
> ST_Line_Substring works on percentages which is smart, but
> I have yet to
> wrap my mind around how to measure each individual line
> such that I can
> translate percentage distance along a linestring into equal
> distance
> intervals.
>
> Anyone have examples or guidance?
>
> Thanks,
>
> Dane
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list