Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from shapely.geometry import Polygon
from matplotlib import pyplot as plt
from shapely.ops import cascaded_union
import geopandas as gpd
m = cascaded_union([Polygon(i if i[0] == i[-1] else i[:-2].append(i[0])) for i in [
[
[81.300003051757812, 37.588695526123047],
[75.599998474121094, 37.588695526123047],
[75.599998474121094, 39.888694763183594],
[71.900001525878906, 39.888694763183594],
[66.5, 39.888694763183594],
[66.5, 43.420764923095703],
[93.5, 41.001277923583984],
[93.5, 39.524875640869141],
[87.199996948242188, 39.524875640869141],
[87.199996948242188, 39.088695526123047],
[81.300003051757812, 39.088695526123047],
[81.300003051757812, 37.588695526123047]
],
[
[87.201118469238281, 39.524875640869141],
[93.5, 39.524875640869141],
[93.5, 41.001277923583984],
[87.201118461238281, 39.524875640869141]
]
]])
boundary = gpd.GeoSeries(cascaded_union(m))
boundary.plot(color='red')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.