2

How do I cut a single line with polygons (in several segments) so that each cut line take data from the polygons? Something like a centroid takes.

  • 1
    In ArcGIS The intersect tool splits the lines at the polygon boundaries and does keep the attributes of each line feature as well as adds in the attributes of the polygon feature that it lies in if the JoinAttributes selection is set to ALL. I would imagine QGIS is similar but I have no experience in it – ed.hank Sep 9 '15 at 19:32
  • You've got an extraordinary set of tags there, but they don't add any value to the question. Please edit the question to contain a graphic of what you want to accomplish, and edit the tags to be relevant to the question. – Vince Sep 9 '15 at 19:33
  • I use qgis 2.10 – nagib Sep 9 '15 at 19:42
  • @user3338197 - Sounds like you solved the problem, consider posting it as an answer instead of a comment :) – Joseph Sep 10 '15 at 10:13
3

Since this appears to solve the users problem Ill add it here.

In ArcGIS and QGIS The intersect tool splits the lines at the polygon boundaries and does keep the attributes of each line feature as well as adds in the attributes of the polygon feature that it lies in if the Join Attributes selection is set to ALL.

0

Just to revive an old question, because this topic is seldom discussed (I wonder why), here is another option using PyQGIS:

If you want to clip a single Geometry by a single rectangle, there is a QgsGeometry::clipped() function that does precisely that.

For clipping a line, one can ignore the alert that this function is not robust - it creates valid geometries from the point where the line enters the rectangle until the point leaving it. When entering the rectangle and leaving it multiple times, the function creates a multilinestring geometry with the intersection parts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.