Skip to content
Advertisement

Why do I get an error when trying to read a file in geopanda’s included datasets?

I’ve just installed Anaconda in my new laptop, and created an environment with geopandas installed in it. I’ve tried to upload the world map that comes with geopandas through the following code:

import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))

But I obtain the following error message:

File ~/anaconda3/envs/mapas_test/lib/python3.8/site-packages/shapely/geometry/base.py:854, in BaseMultipartGeometry.__array_interface__(self)
    851 @property
    852 def __array_interface__(self):
    853     """Provide the Numpy array protocol."""
--> 854     raise NotImplementedError("Multi-part geometries do not themselves "
    855                               "provide the array interface")

NotImplementedError: Multi-part geometries do not themselves provide the array interface

Since this error has never appeared in my old laptop, I guess it is related to some problem during installation, but I could be wrong. Here are the technical details about the installation.

OS: Ubuntu 22.04.1

Python version: 3.9.12

Conda version 4.13.0

geopandas version 0.9.0

Shapely version 1.7.1

And not sure if it is relevant, but the only other package installed in the environment is jupyter version 1.0.0

Advertisement

Answer

This is caused by incompatibility of shapely 1.7 and numpy 1.23. Either update shapely to 1.8 or downgrade numpy, otherwise it won’t work.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement