# How to split a shapely polygon with two linestrings and get the middle polygon

So I have a `shapely` `Polygon` and two `LineString`s. Both `Linestring`s always intersects the polygon. I want to get the polygon in the middle as seen in the example below. The region shaded in red is the polygon I want to get: Anyone know how this can be done in `shapely` or some other Python library?

• Can you convert the two lines to a polygon? This way you can run a simple intersection – Thomas Dec 4 '17 at 23:06

You can recreate a polygon from the lines. In the example below I did it via a convex hull, but there are other possibilities such as creating the polygon ring from the coordinates. After that you can intersect this polygon with the original polygon.

``````from shapely.geometry import LineString, Polygon, MultiLineString

a = LineString([(0, 3), (5, 3)])
b = LineString([(0, 5), (5, 5)])
poly = Polygon([(1, -2), (1, 7), (4, 7), (4, -2)])

# Create a polygon from the lines
multi_line = MultiLineString([a, b])
line_poly = multi_line.convex_hull

# get the intersection
intersection = poly.intersection(line_poly)
print(intersection)
``````