[GIS] GeoPandas Overlay Symmetric Difference: How to get the upper polygon

geopandasoverlay

I have the following code which get the difference of a pie wedges.

c= gp.overlay(a,b,how='symmetric_difference')

enter image description here

How to get the upper polygon?

Best Answer

You just access the c.geometry attribute.

from shapely.geometry import Polygon
import geopandas as gp

poly1 = gp.GeoSeries([Polygon([(0, 3), (3, 3), (1.5, 0), (0, 3)])])
poly2 = gp.GeoSeries([Polygon([(1, 1), (2, 1), (1.5, 0), (1, 1)])])


a = gp.GeoDataFrame({'geometry': poly1, 'a': [1]})
b = gp.GeoDataFrame({'geometry': poly2, 'b': [2]})

c = gp.overlay(a, b, how='symmetric_difference')

print(c.geometry)

0    POLYGON ((0 3, 3 3, 2 1, 1 1, 0 3))
Name: geometry, dtype: object

Poly 1

enter image description here

Poly 2

enter image description here

Symmetric difference

enter image description here

Related Question