Cannot make GeoDataFrame from Shapely Polygons: NotImplementedError: A polygon does not itself provide the array interface. Its rings do

Viewed 2366

This is code that used to work previously, but doesn't anymore:

import geopandas as gp
from shapely.geometry import Polygon

a = Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])
b = Polygon([(0, 1), (0, 2), (1, 2), (1, 1)])
c = Polygon([(1, 0), (1, 1), (2, 1), (2, 0)])
d = Polygon([(1, 1), (1, 2), (2, 2), (2, 1)])
df = gp.GeoDataFrame({"ID": ["a", "b", "c", "d"], "geometry": [a, b, c, d]})

The error I get is this:

NotImplementedError: A polygon does not itself provide the array interface. Its rings do.

Why could this be happening? My GeoPandas version is 0.81 and Shapely version is 1.71.

2 Answers

I got the same error with Shapely==1.7.1 geopandas==0.9.0 numpy==1.23.1, changing numpy==1.22.4 works for me.

Upgrading Shapely==1.8.4 from 1.7.1 resolved my issues.

Related