import shapely.wkt
import matplotlib.pyplot as plt
I have 2 shapely geometries, p
and q
:
p = shapely.wkt.loads("POLYGON((1.4 0.7, 1.8 0.7, 1.8 1.1, 1.4 1.1, 1.4 0.7))")
q = shapely.wkt.loads("MULTIPOLYGON(((1 0.5, 2 0.5, 1.6 0.85, 1 1, 1 1, 1 0.5),(1.5 0.9, 1.6 0.9, 1.6 1, 1.5 0.9)))")
(plot via: gpd.GeoSeries([p,q]).plot(color=['r','b'],alpha=0.5)
)
I would like to remove every vertex from q
within p
. How can I do that?
Expected output is r
, a shapely geometry:
r = shapely.wkt.loads("MULTIPOLYGON(((1 0.5, 2 0.5, 1 1, 1 1, 1 0.5)))")
Visualized (in yellow):
(via gpd.GeoSeries([p,q,r]).plot(color=['r','b','y'],alpha=0.5)
)