GeoSeries.plot do not plot the polygon correctly

Viewed 109

Interesting thing, I defined a polygon with shapely like

from shapely.geometry import Polygon
s = Polygon([(0, 0), (0, 5), (5, 5), (5, 0)], [[(1, 1), (2, 1), (1, 2)], [(1, 4), (2, 4), (2, 3)]])
s

result

but when I put it in a GeoSeris and use the .plot()

import geopandas as gpd
t = gpd.GeoSeries(s)
t.plot()

result2

I want to know what makes the difference. Thank you.

1 Answers

It works if you define the holes anticlockwise:

s = Polygon([(0, 0), (0, 5), (5, 5), (5, 0)], 
            [[(1, 1), (2, 1), (1, 2)], 
             [(1, 4), (2, 3), (2, 4)]])  # instead of: [(1, 4), (2, 4), (2, 3)]
t = gpd.GeoSeries(s)
t.plot()

Might be related to this issue: https://github.com/geopandas/geopandas/issues/951

enter image description here

Related