Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Shell is not a LinearRing" on OSX #34

Closed
ffaristocrat opened this issue Dec 11, 2017 · 19 comments
Closed

"Shell is not a LinearRing" on OSX #34

ffaristocrat opened this issue Dec 11, 2017 · 19 comments

Comments

@ffaristocrat
Copy link

While trying to resolve this issue over in conda-forge/geopandas(shapefile is from that thread), I traced the problem to the version (1.6.3-py36_0) conda-forge is installing for shapely.

Running this from a clean Anaconda install on OSX El Capitan 10.11.6:

conda create --yes --name GEOTEST python=3.6
source activate GEOTEST
conda install --yes -c conda-forge --override-channels geopandas fiona libgdal numpy scipy libgfortran
python -c "import geopandas as gpd; div20m = gpd.read_file('cb_2016_us_division_20m.shp');"

results in repeated

Shell is not a LinearRing
Shell is not a LinearRing
Shell is not a LinearRing
Shell is not a LinearRing
Shell is not a LinearRing
IllegalArgumentException: geometries must not contain null elements

Following on from a suggestion about removing geopandas and pip installing it instead, I repeated it with other libraries as I worked through code in the debugger. I discovered that removing shapely, fiona and geopandas from conda and reinstalling them with pip enables the little one liner test to work. Ditto for code using osmnx that sent me down this rabbit hole in the first place.

conda create --yes --name GEOTEST python=3.6
source activate GEOTEST
conda install --yes -c conda-forge --override-channels geopandas fiona libgdal numpy scipy libgfortran
conda remove --yes fiona shapely geopandas
pip install fiona shapely geopandas
python -c "import geopandas as gpd; div20m = gpd.read_file('cb_2016_us_division_20m.shp');"

The versions being removed from conda:

The following packages will be REMOVED:

    fiona:     1.7.10-py36_2 conda-forge
    geopandas: 0.3.0-py36_0  conda-forge
    shapely:   1.6.3-py36_0  conda-forge

The versions being installed by pip:

Installing collected packages: fiona, shapely, geopandas
Successfully installed fiona-1.7.10.post1 geopandas-0.3.0 shapely-1.6.3

Which, uh, seems to be the same? So I'm not sure what's going on here.

@jorisvandenbossche
Copy link
Member

@ffaristocrat To check this is indeed a shapely issue, could you try to read the file with just fiona? (in the environment where it is failing with geopandas). Then that should not involve shapely or geopandas, and we can see if that works.

Something like

import fiona

# Register format drivers with a context manager
with fiona.drivers():
    # Open a file for reading. We'll call this the "source."
    with fiona.open('...') as source:
        meta = source.meta
        geoms = []
        for fear in source:
            geoms.append(feat['geometry'])

@ffaristocrat
Copy link
Author

conda create --yes --name FIONATEST python=3.6
source activate FIONATEST
conda install --yes -c conda-forge --override-channels geopandas fiona shapely
python -c "import fiona; [f for f in fiona.open('cb_2016_us_division_20m/cb_2016_us_division_20m.shp')];"

This works without any problems. Let me know if you need me to try out anything else.

@jorisvandenbossche
Copy link
Member

OK, that indeed confirms it is a shapely issue, as @ocefpaf also said here conda-forge/geopandas-feedstock#31 (comment)

@ocefpaf
Copy link
Member

ocefpaf commented Dec 20, 2017

Note that we are seeing some incompatibilities in the latest OS X system and shapely. I cannot reproduce that using the OS X VM available in Travis-CI and I do not own a Mac to research this further.

Using pip works b/c they are static linked, this suggests that latest OS X may have a system wide geos installed, not sure. If so, the patch we have to find conda geos is not working 😒

TL;DR I have no idea what the issue really is and I do not have the tools to fix it.

@jhagege
Copy link

jhagege commented Mar 12, 2018

+1, any solution found ?
Thanks !

@phobson
Copy link
Member

phobson commented Mar 12, 2018

@ocefpaf I'll try to reproduce this on my machine at home tonight (US/Pacific time).

@ocefpaf
Copy link
Member

ocefpaf commented Mar 12, 2018

Thanks @phobson!

@denadai2
Copy link

+1

@adah1972
Copy link

Reinstalling only geopandas via pip (fiona and shapely are still installed by conda) solved the problem for me.

@Fil
Copy link

Fil commented May 4, 2018

same issue for me, & nothing seems to work :(

@j-la-haye
Copy link

j-la-haye commented Jun 15, 2018

Any update here for MacOS? I have reinstalled geopandas via pip and (fiona and shapely are still installed by conda) but still getting 'Shell is not a LinearRing' when trying to call define a shapely Polygon.

@Fil
Copy link

Fil commented Jun 15, 2018

I forgot to give a solution that worked for me, maybe it will help:

conda create -n isochrones # name your virtual env as you like, I chose 'isochrones' for some reason
source activate isochrones
conda config --add channels conda-forge
conda install -n isochrones geopandas ipython bokeh requests osmnx jsonschema pandas pyproj geojson geopy Shapely numpy

@ocefpaf
Copy link
Member

ocefpaf commented Jun 15, 2018

We cannot reproduce this issue and people that follow our instructions are reporting successful installations.

I'm closing this. If you are still experiencing this issue please try to investigate if your OS X has a geos pre-installed and if shapely is picking that one up.

@ocefpaf ocefpaf closed this as completed Jun 15, 2018
@j-la-haye
Copy link

j-la-haye commented Jun 23, 2018

Hi @ocefpaf , Thanks for the advice. I have applied the conda config instructions listed. I am still having issues unfortunately. Any pointers as to how I can verify/prevent shapely from using the system OSX geos? Does installing a conda-forge version of geos over ride the system installation? Perhaps removing the system version of geos from my Frameworks directory?

@ocefpaf
Copy link
Member

ocefpaf commented Jun 26, 2018

Any pointers as to how I can verify/prevent shapely from using the system OSX geos?

I'm not even sure that is the problem. I don't have a Mac and our Mac-CI (Travis-CI OS X image) does not reproduce the problem.

We would need a Mac users that is more comfortable with conda and the issues here to debug this.

@phobson
Copy link
Member

phobson commented Jun 29, 2018

Just did the following on Mac OS 10.13.5:

$ conda create --name=gistest --channel=conda-forge python=3.6 geopandas --yes
$ source activate gistest
$ python -c "import geopandas as gpd; div20m = gpd.read_file('cb_2016_us_division_20m.shp'); print(div20m.shape);"

And it printed (9, 8)

@adah1972
Copy link

I do not think there is a system-wide libgeos. At least I cannot find any libgeos* under /usr/lib and /System/Library.

I solved my problem by reinstalling geopandas from pip. However, I have now tried pip uninstall geopandas followed by conda install geopandas, everything seems to be OK at the moment. The original issue could be solved by an update, or it could be a conflict with another channel…

@adah1972
Copy link

Btw, I have tried both the default channel and conda-forge. No errors were encountered.

@ocefpaf
Copy link
Member

ocefpaf commented Jun 29, 2018

Thanks @phobson and @adah1972 for testing. Your results matches our CI 🎉

People still suffering from this issue either have a unique setup or are not really following the channel best practices recommended the docs.

@conda-forge conda-forge locked and limited conversation to collaborators Oct 7, 2021
@conda-forge conda-forge deleted a comment from ginaliqili Oct 7, 2021
@conda-forge conda-forge deleted a comment from kirankumargmrur Oct 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants