I have been trying to use Shapely to split a shapefile with multiple features at regular intervals. I have used the split function to do this. I can easily create the points at which the lines should be split, but when I then split nothing happens.
What am I missing?
import fiona
import shapely
from shapely.ops import split
from shapely.geometry import *
schema = {
'geometry': 'MultiLineString',
'properties': {'id': 'int'},
}
with fiona.open("./test_depth.shp") as inp:
with fiona.open('result3.shp', 'w', 'ESRI Shapefile', schema) as out:
for line in inp:
geom = shape(line['geometry'])
length = geom.length
for i, distance in enumerate(range(0, int(length), 10)):
point = geom.interpolate(distance)
split_line = shapely.geometry.MultiLineString(split(geom,point))
print(split_line)
out.write({'geometry': mapping(split_line),'properties': {'id': 1}})