0

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?

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.