In FME you can use a ModuloCounter transformer to number features in groups of 200. Then use a Feature Type Fanout (open the Feature Type properties, set the fanout By Attribute option, and select the ModuloCounter attribute).
The only issue is the 200 features per file might not be spatially related in any way - you'd have to do some form of tiling to get that - but it might not be a problem for you anyway.
You have many solutions and I use here a simple example
1) the easiest way
from shapely.geometry import Point, LineString
line = LineString([(1,2),(2,4),(4,5)])
point = Point(2,4)
First, you must determine if the point is within the line (Determine if shapely point is within a linestring/multilinestring)
line.distance(point) < 1e-8
True
print LineString([line.coords[0],point.coords[:][0]])
LINESTRING (1 2, 2 4)
print LineString([point.coords[:][0], line.coords[-1]])
LINESTRING (2 4, 4 5)
2) with the shapely function split
from shapely.ops import split
result = split(line, point)
result.wkt
'GEOMETRYCOLLECTION (LINESTRING (1 2, 2 4), LINESTRING (2 4, 4 5))'
3) from Get the vertices on a LineString either side of a Point
from shapely.geometry import Point,LineString
def split(line_string, point):
coords = line_string.coords
j = None
for i in range(len(coords) - 1):
if LineString(coords[i:i + 2]).intersects(point):
j = i
break
assert j is not None
# Make sure to always include the point in the first group
if Point(coords[j + 1:j + 2]).equals(point):
return coords[:j + 2], coords[j + 1:]
else:
return coords[:j + 1], coords[j:]
line1,line2 = split(line,point)
line1 = LineString(line1)
line2 = LineString(line2)
print line1, line2
LINESTRING (1 2, 2 4) LINESTRING (2 4, 4 5)
4) from Shapely Split LineStrings at Intersections with other LineStrings
# First coords of line (start + end)
coords = [line.coords[0], line.coords[-1]]
# Add the coords from the points
coords += point.coords
# Calculate the distance along the line for each point
dists = [line.project(Point(p)) for p in coords]
# sort the coordinates
coords = [p for (d, p) in sorted(zip(dists, coords))]
lines = [LineString([coords[i], coords[i+1]]) for i in range(len(coords)-1)]
for lin in lines:
print lin
LINESTRING (1 2, 2 4)
LINESTRING (2 4, 4 5)
5) you can also examine and adapt
Best Answer
Have you tried first making an intersection with the grid layer and then using
Vector -> Data managment tools -> Split vector layer
? It sounds exactly like what you want.