Skip to main content
Question

Cut and shorten linestrings around object

  • June 30, 2022
  • 3 replies
  • 27 views

Example. I have 1 linestring going into the object and 1 linestring coming out from the object.

 

Use case 1: I should simply shorten both linestrings so that there will be a buffer around object. So I should shorten linestring 1 from the end and linestring 2 from the start

 

Use case 2: I should cut both linestrings using area and then shorten all 4 a bit next to the area. But how do I know which way the linestrings are and how to shorten specifically from the end or from the start? image

3 replies

geomancer
Evangelist
Forum|alt.badge.img+58
  • Evangelist
  • 932 replies
  • June 30, 2022

Buffer the object (Bufferer), and clip the lines (Clipper), keeping the outside geometries.

Buffer_and_Clip 


  • Author
  • 5 replies
  • June 30, 2022

This helps for use case #1 and mostly to use case #2 as well but with that I should also know which side of the remaining lines stays as-is. Is there any attribute to tell that directly, I mean if linestring has the original startingpoint or endingpoint?


geomancer
Evangelist
Forum|alt.badge.img+58
  • Evangelist
  • 932 replies
  • June 30, 2022

You can write the coordinates of the start (or end) point of the original linestring to attributes with a CoordinateExtractor, and afterwards compare the coordinates of the start (or end) point of the clipped linestring to determine which side was clipped.