Tag Info

New answers tagged

1

The easiest solution is to use union, cascaded_unionor unary_union. All the lines are split at the points of intersection: from shapely.geometry import LineString line1 = LineString([(0, 0), (2, 2),(3,1)]) line2 = LineString([(2, 0), (2, 1),(1,2)]) print line1.intersection(line2) POINT (1.5 1.5) for line in line1.union(line2): print line LINESTRING (0 ...


0

This should go as a comment. But is too long. Thanks much Gene! There are both LineString and MultiLineString features. So this code for line in shape(elem['geometry']) shows TypeError: 'LineString' object is not iterable when feature is MultiLineString. So the final code that works is as below. with fiona.open(source_path) as source: with ...


2

A MultiLineString is a list of lines: from shapely.geometry import MultiLineString, mapping, shape coords = [((0, 0), (1, 1)), ((-1, 0), (1, 0))] lines = MultiLineString(coords) print lines MULTILINESTRING ((0 0, 1 1), (-1 0, 1 0)) for line in lines: print line LINESTRING (0 0, 1 1) LINESTRING (-1 0, 1 0) # convert to GeoJSON format: print ...



Top 50 recent answers are included