Search code examples
pythonpython-xarraycartopyrasterio

cartopy: import cartopy.crs error


I'm working on some development for xarray. I was trying to install rasterio but it seems to have messed up my cartopy installation.

I installed rasterio on my mac using:

brew install gdal
pip install rasterio

Now when I try import cartopy.crs as ccrs I get the error

Invalid argument (must be a Polygon)
Geometry must be a Point or LineString
Assertion failed: (0 != cs), function GEOSCoordSeq_getSize_r, file geos_ts_c.cpp, line 3991.
Abort trap: 6

Possibly something with the paths/versions of GEOS, PROJ4 or GDAL changed?

Is there a way to do a clean installation of cartopy which will grab the dependencies?

I originally installed cartopy using conda install -c conda-forge cartopy. Doing conda update cartopy doesn't really do anything as I have the latest version.

Any help will be greatly appreciated as I do a large portion of my work with cartopy.

Edit: some discussion about this here https://github.com/SciTools/cartopy/issues/612

$ geos-config --version 3.6.2

Tried

conda remove xarray cartopy rasterio gdal geos proj4 shapely
conda install -c conda-forge xarray cartopy rasterio gdal geos proj4 shapely

but to no avail


Solution

  • cartopy was picking up the geos directory from the brew install gdal. I therefore removed this using:

    $ brew tap beeftornado/rmtree
    $ brew rmtree gdal
    $ brew uninstall --ignore-dependencies proj
    $ brew uninstall --ignore-dependencies geos
    $ brew uninstall --ignore-dependencies json-c
    $ brew uninstall --ignore-dependencies freexl
    $ brew uninstall --ignore-dependencies liblwgeom
    

    cartopy then correctly picked up the geos directory which is installed during the conda installation of cartopy.