3

Once you have line and polygon geometries, intersection using Shapely is very straight forward. What I did after that is to integrate all the looped 'intersected' geometries into a MultiLineString.

Now my query is, while mapping the MultiLineString using Fiona, the output is a single geometry, with a single attribute. If I could add individual attributes to each intersection geometry result, my MultiLineString would consist of multiple geometries.

How do I add a property or attribute to a LineString once the geometry is ready???

This problem is with reference to previous issues.

Step One - Vertical Lines in a Polygon Shapefile

Step Two - Clipping Line shapefiles to within the Extent of Polygon

The reason why I am doing this is because once I have the geometries of all the clipped lines, I need to extract the Node coordinates of each of them.

Akhil
  • 1,435
  • 3
  • 19
  • 24

1 Answers1

4

Shapely geometries are python classes, so you can simply set a new property in the object.

For my use-cases this has worked, though it may be worth checking for unintended side-effects depending on your scenario.

from shapely import geometry

p = geometry.Point(0, 0)
p.uid = 'unique point'
print(p.uid)  # prints: 'unique point'
songololo
  • 1,694
  • 14
  • 19