osmnx: graph_from_place giving networkx NetworkXPointlessConcept Exception

I am trying to follow the article on the link here (awesome blog btw).

However, every time I try to get a graph from a place using graph_from_place I get the following error:

  File "/home/manuel/miniconda3/envs/test/lib/python3.5/site-packages/osmnx/osmnx.py", line 1815, in graph_from_place
    truncate_by_edge=truncate_by_edge, name=name, timeout=timeout, memory=memory, max_query_area_size=max_query_area_size, clean_periphery=clean_periphery)
  File "/home/manuel/miniconda3/envs/test/lib/python3.5/site-packages/osmnx/osmnx.py", line 1749, in graph_from_polygon
    G = truncate_graph_polygon(G_buffered, polygon, retain_all=retain_all, truncate_by_edge=truncate_by_edge)
  File "/home/manuel/miniconda3/envs/test/lib/python3.5/site-packages/osmnx/osmnx.py", line 1320, in truncate_graph_polygon
    G = get_largest_component(G)
  File "/home/manuel/miniconda3/envs/test/lib/python3.5/site-packages/osmnx/osmnx.py", line 1099, in get_largest_component
    if not nx.is_weakly_connected(G):
  File "<decorator-gen-62>", line 2, in is_weakly_connected
  File "/home/manuel/miniconda3/envs/test/lib/python3.5/site-packages/networkx/utils/decorators.py", line 68, in _not_implemented_for
    return f(*args,**kwargs)
  File "/home/manuel/miniconda3/envs/test/lib/python3.5/site-packages/networkx/algorithms/components/weakly_connected.py", line 178, in is_weakly_connected
    """Connectivity is undefined for the null graph.""")
networkx.exception.NetworkXPointlessConcept: Connectivity i

gdf_from_place works, as well as graph_from_point .

I am using spatialindex=1.8.5

The environment’s packages:

click==6.6
click-plugins==1.0.3
cligj==0.4.0
cycler==0.10.0
decorator==4.0.10
descartes==1.0.2
Fiona==1.7.1
geopandas==0.2.1
geopy==1.11.0
matplotlib==1.5.3
munch==2.0.4
networkx==1.11
numpy==1.11.2
OSMnx==0.1a1
pandas==0.19.1
pyparsing==2.1.10
pyproj==1.9.5.1
python-dateutil==2.6.0
pyttsx==1.1
pytz==2016.7
requests==2.12.1
Rtree==0.8.2
Shapely==1.5.17
six==1.10.0

My machine’s watermark:

2016-11-28T15:33:21+01:00

CPython 3.5.1
IPython 4.2.0

compiler   : GCC 4.4.7 20120313 (Red Hat 4.4.7-1)
system     : Linux
release    : 4.4.0-47-generic
machine    : x86_64
processor  : x86_64
CPU cores  : 8
interpreter: 64bit

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 25 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Just tested that, and… it worked !!

I just uninstalled previous rtree version with :

sudo pip3 uninstall rtree (just use pip if you’re using Python 2.7)

Then :

sudo pip3 install --upgrade https://github.com/Toblerity/rtree/tarball/master

And the beautiful Modena finally appears !

modena

Ok, I managed to re-create the problem and got it solved for Ubuntu desktop now as well.

It appears to be an rtree bug that affects the combination of rtree 0.8.2 + libspatialindex 1.8.5 + Linux. This bug was not reproducible for me on Mac or Windows. The bug is documented in an issue in rtree’s GitHub repo, and it was recently fixed but hasn’t been released yet. But you can fix it in the meantime by installing the GitHub version of rtree:

pip install --upgrade https://github.com/Toblerity/rtree/tarball/master

That got it working for me.

For reference, here are the full steps I took starting with a fresh installation of Ubuntu 16.10. First I installed Miniconda and pip, then ran:

conda config --add channels conda-forge
conda install requests networkx geopy geopandas
sudo apt-get install libspatialindex-dev
pip install --upgrade https://github.com/Toblerity/rtree/tarball/master
pip install osmnx

This adds the conda-forge channel, installs the required packages and libspatialindex, upgrades rtree to the GitHub development version, then installs OSMnx. It’s using spatialindex 1.8.5, 64-bit Python 3.5.1 on Ubuntu 16.10 with kernel 4.8.0-22-generic. Here’s the complete list of Python packages installed in the environment (but note that rtree is in fact the upgraded GitHub dev version):

click==6.6
click-plugins==1.0.3
cligj==0.4.0
conda==4.2.13
cycler==0.10.0
decorator==4.0.10
descartes==1.0.2
Fiona==1.7.1
GDAL==2.1.2
geopandas==0.2.1
geopy==1.11.0
matplotlib==1.5.3
munch==2.0.4
networkx==1.11
numpy==1.11.2
osmnx==0.1b2
pandas==0.19.1
psycopg2==2.6.2
pycosat==0.6.1
pycrypto==2.6.1
pyparsing==2.1.10
pyproj==1.9.5.1
PySAL==1.13.0
python-dateutil==2.6.0
pytz==2016.7
requests==2.12.1
Rtree==0.8.2
ruamel-yaml===-VERSION
scipy==0.18.1
Shapely==1.5.17
six==1.10.0
SQLAlchemy==1.1.4

EDIT: this rtree bug was fixed in the release of rtree 0.8.3.