10

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.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
bsuw
  • 101
  • 1
  • 3
  • your code looks fine. i tired it with geopands 0.8.1 and shapely 1.71 and it worked too. any other logs or changes you can think of? – eth4io Jan 12 '21 at 04:12
  • any update on this? I believe it should be the installation. I got the same error when opening gjson files with geopandas – Ricardo Gomes Jul 01 '22 at 10:34
  • What version of `numpy` do you have? I had it work with `Shapely==1.7.1`, `geopandas==0.10.2`, `numpy==1.20.3` – Binx Jul 14 '22 at 00:13

3 Answers3

9

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.

Yingbin
  • 91
  • 1
  • 4
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 26 '22 at 00:43
  • If you are using conda for updating packages: the suggested numpy version (1.22.4) is currently not available from the default conda channel. So you first need to add the conda-forge channel: `conda config --append channels conda-forge`. Then, you will be able to download the newer version of numpy: `conda install numpy>=1.22.4`. – Sander Vanden Hautte Aug 19 '22 at 11:05
5

Upgrading Shapely==1.8.4 from 1.7.1 resolved my issues.

chenste
  • 51
  • 1
  • 1
1

The error NotImplementedError: Component rings have coordinate sequences, but the polygon does not typically occurs when attempting to convert a polygonal geometry object (Polygon) to a list of coordinates using the coords property and the geometry object does not have an associated list of coordinates.

To fix this error, make sure that the geometry object you are trying to convert is a valid polygonal geometry object and has an associated list of coordinates. One way to do this is to use the exterior.coords method instead of coords to access the coordinates of the polygon.