Giter Club home page Giter Club logo

gboeing / osmnx Goto Github PK

View Code? Open in Web Editor NEW
4.7K 114.0 801.0 7.36 MB

OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap.

Home Page: https://osmnx.readthedocs.io

License: MIT License

Python 98.03% Dockerfile 0.38% Batchfile 0.18% Shell 1.41%
openstreetmap gis street-networks overpass-api networkx spatial-analysis geospatial urban-planning transportation geography

osmnx's Introduction

PyPI Version PyPI Downloads Anaconda Downloads Documentation Status Build Status Coverage Status

OSMnx

OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap. You can download and model walking, driving, or biking networks with a single line of code then analyze and visualize them. You can just as easily work with urban amenities/points of interest, building footprints, transit stops, elevation data, street orientations, speed/travel time, and routing.

OSMnx 2.0 is coming soon: read the migration guide.

Citation

If you use OSMnx in your work, please cite the journal article:

Boeing, G. 2017. "OSMnx: New Methods for Acquiring, Constructing, Analyzing, and Visualizing Complex Street Networks." Computers, Environment and Urban Systems 65, 126-139.

Getting Started

First read the Getting Started guide for an introduction to the package and FAQ.

Then work through the OSMnx Examples gallery for step-by-step tutorials and sample code.

Installation

Follow the Installation guide to install OSMnx.

Support

If you have any trouble, consult the User Reference. The OSMnx repository is hosted on GitHub. If you have a "how-to" or usage question, please ask it on StackOverflow, as we reserve the repository's issue tracker for bug tracking and feature development.

License

OSMnx is open source and licensed under the MIT license. OpenStreetMap's open data license requires that derivative works provide proper attribution. Refer to the Getting Started guide for usage limitations.

osmnx's People

Contributors

a-gerhard avatar andreytyu avatar anisotropi4 avatar atelierlibre avatar benafischer94 avatar d-wasserman avatar davidbreuer avatar davidmurray avatar eumiro avatar ewouth avatar gboeing avatar groundrace avatar guibar avatar htenkanen avatar ilyaorson avatar kjacks21 avatar kuanb avatar martinfleis avatar mctoel avatar migurski avatar mxndrwgrdnr avatar ncotie avatar nickodell avatar pmartincalvo avatar pmlpm1986 avatar ppintosilva avatar runorveith avatar samuelduchesne avatar sebmilardo avatar yonghah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osmnx's Issues

Error loading building outlines

I'm trying to follow the building outline example for my city, but am having problems retrieving the data.

I've tried:

gdf = ox.buildings_from_place(place='Bath, United Kingdom')

But this generates:

Retrieved response from cache file "cache/4dd9e9bd0481bfc73438754979de4014.json" for URL "https://nominatim.openstreetmap.org/search?format=json&limit=1&dedupe=0&polygon_geojson=1&q=Bath%2C+United+Kingdom"
OSM returned a Point as the geometry.
Created GeoDataFrame with 1 row for query "Bath, United Kingdom"
Projected the GeoDataFrame "geometry to project" to UTM-30 in 0.00 seconds
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ldodds/tools/anaconda2/envs/OSMNX/lib/python2.7/site-packages/osmnx/buildings.py", line 225, in buildings_from_place
    return create_buildings_gdf(polygon)
  File "/home/ldodds/tools/anaconda2/envs/OSMNX/lib/python2.7/site-packages/osmnx/buildings.py", line 120, in create_buildings_gdf
    results = osm_bldg_download(polygon, north, south, east, west)
  File "/home/ldodds/tools/anaconda2/envs/OSMNX/lib/python2.7/site-packages/osmnx/buildings.py", line 85, in osm_bldg_download
    geometry_proj_consolidated_subdivided = consolidate_subdivide_geometry(geometry_proj, max_query_area_size=max_query_area_size)
  File "/home/ldodds/tools/anaconda2/envs/OSMNX/lib/python2.7/site-packages/osmnx/core.py", line 550, in consolidate_subdivide_geometry
    raise ValueError('Geometry must be a shapely Polygon or MultiPolygon')
ValueError: Geometry must be a shapely Polygon or MultiPolygon

The cache file contains:

[{"display_name": "Bath, South West England, England, BA1, UK", "importance": 0.70803439318359, "place_id": "104804", "lon": "-2.3596962", "geojson": {"type": "Point", "coordinates": [-2.3596962, 51.3813864]}, "lat": "51.3813864", "osm_type": "node", "licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright", "osm_id": "1947201", "boundingbox": ["51.2213864", "51.5413864", "-2.5196962", "-2.1996962"], "type": "city", "class": "place", "icon": "https://nominatim.openstreetmap.org/images/mapicons/poi_place_city.p.20.png"}]

I notice with the Piedmont example the node that is returned is of type boundary. So I thought it might be having problems resolving the right location.

I've also tried specifying the point as a lat, long and instead called buildings_from_point but this also fails (`KeyError: 'geometry') which I suspect is also data related.

However OSM does seem to have building outlines for the city:

http://www.openstreetmap.org/node/1947201#map=17/51.38146/-2.35869

Any ideas?

Geometry must be a shapely Polygon or MultiPolygon

I'm sorry, I always show you errrors :(

import osmnx as ox
G = ox.graph_from_place('Povo, Italy', simplify=False)
ox.plot_graph(G, node_color='b', node_zorder=3)

which result is:

ValueError                                Traceback (most recent call last)
<ipython-input-23-55f613d01d8f> in <module>()
      1 import osmnx as ox
----> 2 G = ox.graph_from_place('Povo, Italy', simplify=False)
      3 ox.plot_graph(G, node_color='b', node_zorder=3)

/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/osmnx/osmnx.py in graph_from_place(query, network_type, simplify, retain_all, truncate_by_edge, name, which_result, buffer_dist, timeout, memory, max_query_area_size, clean_periphery)
   1815     # create graph using this polygon(s) geometry
   1816     G = graph_from_polygon(polygon, network_type=network_type, simplify=simplify, retain_all=retain_all, 
-> 1817                            truncate_by_edge=truncate_by_edge, name=name, timeout=timeout, memory=memory, max_query_area_size=max_query_area_size, clean_periphery=clean_periphery)
   1818 
   1819     log('graph_from_place() returning graph with {:,} nodes and {:,} edges'.format(len(G.nodes()), len(G.edges())))

/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/osmnx/osmnx.py in graph_from_polygon(polygon, network_type, simplify, retain_all, truncate_by_edge, name, timeout, memory, max_query_area_size, clean_periphery)
   1730         raise ValueError('Shape does not have a valid geometry')
   1731     if not isinstance(polygon, (Polygon, MultiPolygon)):
-> 1732         raise ValueError('Geometry must be a shapely Polygon or MultiPolygon')
   1733 
   1734     if clean_periphery and simplify:

ValueError: Geometry must be a shapely Polygon or MultiPolygon

osmnx doesn't run with Arch Linux python packages

If I try to run ox.plot_graph(ox.graph_from_place('Modena, Italy')) Ii get:

AttributeError: module 'osmnx' has no attribute 'plot_graph'

When executing the example

city = ox.gdf_from_place('Berkeley, CA')
ox.plot_shape(ox.project_gdf(city))

it throws:
AttributeError: module 'osmnx' has no attribute 'gdf_from_place'

I've installed (lib)spatialindex 1.8.5, geopandas 0.1.1, fiona 1.7.1, matplotlib 2.0.0 and version 0.2.2 of osmnx. May you please help me with the dependencies?

City graph seems to lose some edges

Problem description

City graph and building footprint do not match if put together in a two layer picture

Mac OSX 10.11.6 (El Capitan), Python 2.7.10, OSMnx 0.4.

Complete list of your environment's packages and their versions:

zsh-% pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
appdirs (1.4.3)
appnope (0.1.0)
backports-abc (0.5)
backports.shutil-get-terminal-size (1.0.0)
bleach (2.0.0)
certifi (2017.1.23)
click (6.7)
click-plugins (1.0.3)
cligj (0.4.0)
configparser (3.5.0)
cycler (0.10.0)
decorator (4.0.11)
descartes (1.1.0)
entrypoints (0.2.2)
enum34 (1.1.6)
Fiona (1.7.4)
functools32 (3.2.3.post2)
geopandas (0.2.1)
html5lib (0.999999999)
ipykernel (4.5.2)
ipython (5.3.0)
ipython-genutils (0.2.0)
ipywidgets (6.0.0)
Jinja2 (2.9.5)
jsonschema (2.6.0)
jupyter (1.0.0)
jupyter-client (5.0.0)
jupyter-console (5.1.0)
jupyter-core (4.3.0)
MarkupSafe (1.0)
matplotlib (2.0.0)
mistune (0.7.4)
munch (2.1.0)
nbconvert (5.1.1)
nbformat (4.3.0)
networkx (1.11)
notebook (4.4.1)
numpy (1.12.1)
osmnx (0.4)
packaging (16.8)
pandas (0.19.2)
pandocfilters (1.4.1)
pathlib2 (2.2.1)
pexpect (4.2.1)
pickleshare (0.7.4)
pip (9.0.1)
prompt-toolkit (1.0.13)
ptyprocess (0.5.1)
Pygments (2.2.0)
pyparsing (2.2.0)
pyproj (1.9.5.1)
python-dateutil (2.6.0)
pytz (2016.10)
pyzmq (16.0.2)
qtconsole (4.2.1)
requests (2.13.0)
Rtree (0.8.3)
scandir (1.5)
setuptools (34.3.2)
Shapely (1.5.17.post1)
simplegeneric (0.8.1)
singledispatch (3.4.0.3)
six (1.10.0)
subprocess32 (3.2.7)
terminado (0.6)
testpath (0.3)
tornado (4.4.2)
traitlets (4.3.2)
wcwidth (0.1.7)
webencodings (0.5)
wheel (0.29.0)
widgetsnbextension (2.0.0)
zsh-%

Code that reproduces the issue

import osmnx as ox
from IPython.display import Image
%matplotlib inline
ox.config(log_console=True, use_cache=True)

def make_plot(place, point, network_type='drive', bldg_color='orange', dpi=90,
              dist=805, default_width=4, street_widths=None):
    gdf = ox.buildings_from_point(point=point, distance=dist)
    gdf_proj = ox.project_gdf(gdf)
    fig, ax = ox.plot_figure_ground(point=point, dist=dist, network_type=network_type, default_width=default_width,
                                    street_widths=street_widths, save=False, show=False, close=True)
    fig, ax = ox.plot_buildings(gdf_proj, fig=fig, ax=ax, color=bldg_color, set_bounds=False,
                                save=True, show=False, close=True, filename=place, dpi=dpi)

place = 'gante'
point = (51.05660,3.721500)
make_plot(place, point, network_type='walk', default_width=3, street_widths={'primary':3}, dist=525)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)

location_point = (51.05660,3.721500)

# create network from point, inside bounding box 
G2 = ox.graph_from_point(location_point, distance=525, distance_type='bbox', network_type='walk')
#                        simplify='True',retain_all='False', truncate_by_edge = 'False')
G2 = ox.project_graph(G2)
fig, ax = ox.plot_graph(G2, node_size=2, node_color='#66cc66')

10-building-footprints&Gante.ipynb.zip

save_graphml and load_graphml do not seem to work together

Hi,

I have got an error when I try to resave a previously loaded file with python 2.7, networkx 1.11 (debian package) and osmnx from master.
Here is an exemple:

import osmnx as ox

place = 'Paris, France'
G = ox.graph_from_place(place, network_type='drive', simplify=False)
ox.save_graphml(G, 'parisTest.graphml')

G2 = ox.load_graphml('parisTest.graphml')
ox.save_graphml(G2, 'parisTest2.graphml')

I get the following error:

ox.save_graphml(G2, 'parisTest2.graphml')
File "build/bdist.linux-x86_64/egg/osmnx/save_load.py", line 179, in save_graphml
File "", line 2, in write_graphml
File "/usr/lib/python2.7/dist-packages/networkx/utils/decorators.py", line 220, in _open_file
result = func(*new_args, **kwargs)
File "/usr/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 82, in write_graphml
writer.add_graph_element(G)
File "/usr/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 350, in add_graph_element
self.add_nodes(G,graph_element)
File "/usr/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 307, in add_nodes
self.add_attributes("node", node_element, data, default)
File "/usr/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 298, in add_attributes
default_value=default.get(k)
AttributeError: 'unicode' object has no attribute 'get'

Do you understand what happens ?
Thanks,

UTF-8 encoding with save_graph_shapefile function error

Hello Geoff !

I was retesting an interesting case with the new update of save_graph_shapefile function (which includes now an UTF-8 encoding). I'm sure that I was using 0.1 version of OSMnx !

Here's the beginning of my code :


%matplotlib inline
import osmnx as ox, matplotlib.pyplot as plt
from shapely.geometry import Polygon, MultiPolygon, shape
ox.config(log_console=True, use_cache=True)

liege_streets = ox.graph_from_place('Liège, Belgique', network_type='walk', retain_all=True)
liege_streets = ox.project_graph(liege_streets)

fig, ax = ox.plot_graph(liege_streets, fig_height=10, show=False, node_size=0, close=False, edge_color='#777777')

plt.show

The street network of Liège is displaying well, everything is cool so far. Then, I want to save these network on the .shp format, with the command :
ox.save_graph_shapefile(rues_liege, filename='rues_liege')

But then, got this error :

ERROR:Fiona:Failed to encode property 'name' value 'Place Crève Cœur'
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-19-d96d6a09437d> in <module>()
----> 1 ox.save_graph_shapefile(rues_liege, filename='rues_liege')

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in save_graph_shapefile(G, filename, folder)
   2070     # save the nodes and edges as separate ESRI shapefiles
   2071     gdf_nodes.to_file('{}/nodes'.format(folder))
-> 2072     gdf_edges.to_file('{}/edges'.format(folder))
   2073     log('Saved graph "{}" to disk as shapefiles at "{}" in {:,.2f} seconds'.format(G_save.name, folder, time.time()-start_time))
   2074 

/usr/local/lib/python3.4/dist-packages/geopandas/geodataframe.py in to_file(self, filename, driver, schema, **kwargs)
    341         """
    342         from geopandas.io.file import to_file
--> 343         to_file(self, filename, driver, schema, **kwargs)
    344 
    345     def to_crs(self, crs=None, epsg=None, inplace=False):

/usr/local/lib/python3.4/dist-packages/geopandas/io/file.py in to_file(df, filename, driver, schema, **kwargs)
     61                     schema=schema, **kwargs) as c:
     62         for feature in df.iterfeatures():
---> 63             c.write(feature)
     64 
     65 

/usr/local/lib/python3.4/dist-packages/fiona/collection.py in write(self, record)
    333     def write(self, record):
    334         """Stages a record for writing to disk."""
--> 335         self.writerecords([record])
    336 
    337     def validate_record(self, record):

/usr/local/lib/python3.4/dist-packages/fiona/collection.py in writerecords(self, records)
    327         if self.mode not in ('a', 'w'):
    328             raise IOError("collection not open for writing")
--> 329         self.session.writerecs(records, self)
    330         self._len = self.session.get_length()
    331         self._bounds = self.session.get_extent()

/usr/local/lib/python3.4/dist-packages/fiona/ogrext.cpython-34m.so in fiona.ogrext.WritingSession.writerecs (fiona/ogrext1.c:17864)()

/usr/local/lib/python3.4/dist-packages/fiona/ogrext.cpython-34m.so in fiona.ogrext.OGRFeatureBuilder.build (fiona/ogrext1.c:7091)()

/usr/local/lib/python3.4/dist-packages/fiona/ogrext.cpython-34m.so in fiona.ogrext.OGRFeatureBuilder.build (fiona/ogrext1.c:6935)()

UnicodeEncodeError: 'latin-1' codec can't encode character '\u0153' in position 13: ordinal not in range(256)

PS : the first time I run the command, I haven't got these error but another one more soft. But then I refresh it on my notebook, got the previous one !

Documentation

I apologize but this is going to be a basic use question.

To get started after installing do I:

Launch the environment with source activate osmnx or go to python
Then, do I just run

`import osmnx as ox
from IPython.display import Image
%matplotlib inline
ox.config(log_console=True, use_cache=True)`

or do I save into a .py file and run the script?

AttributeError: dlsym(RTLD_DEFAULT, Error_GetLastErrorNum): symbol not found

Hello.
'pip install osmnx'
fails at rtree:
Collecting rtree>=0.8 (from osmnx)
Using cached Rtree-0.8.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/6g/7qfb0g056b14k5jr15p7x65r0000gs/T/pip-build-8aelx0az/rtree/setup.py", line 4, in
import rtree
File "/private/var/folders/6g/7qfb0g056b14k5jr15p7x65r0000gs/T/pip-build-8aelx0az/rtree/rtree/init.py", line 1, in
from .index import Rtree
File "/private/var/folders/6g/7qfb0g056b14k5jr15p7x65r0000gs/T/pip-build-8aelx0az/rtree/rtree/index.py", line 6, in
from . import core
File "/private/var/folders/6g/7qfb0g056b14k5jr15p7x65r0000gs/T/pip-build-8aelx0az/rtree/rtree/core.py", line 110, in
rt.Error_GetLastErrorNum.restype = ctypes.c_int
File "/usr/local/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ctypes/init.py", line 360, in getattr
func = self.getitem(name)
File "/usr/local/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ctypes/init.py", line 365, in getitem
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, Error_GetLastErrorNum): symbol not found

Toblerity/rtree has an open issue about it, I'm running
Os X 10.12.1, python 3.5.2.

overpass_request Exception: Server returned no JSON data.

Trying to follow your examples/tutorials and each time I run any "graph_from_*" method I get an exception:

Exception: Server returned no JSON data.
<Response [404]> Not Found
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>404 - File or directory not found.</h2>
  <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
 </fieldset></div>
</div>
</body>
</html>

I'm in Windows 7, installed osmnx via

conda install -c conda-forge osmnx

and pretty sure I have necessary dependencies.

Please let me know if I can add further details about my setup.

Thanks so much in advance!

clean_intersections geoseries only returning one observation

Trying to get the clean intersections from within a polygon as efficiently as possible. I've hacked it down to the following. I understand the output of ox.clean_intersections should be a geoseries, but i only returns one observation here. Not sure if I'm missing something or if it's a problem in osmnx.

I'm on Mac OS 10.12.3, using python 2.7.13, OSMnx 0.51 (direct from github)

import osmnx as ox, geopandas as gpd
%matplotlib inline
ox.config(log_file=True, log_console=True, use_cache=True)

cbsa = gpd.read_file('cbsa.shp')
metro = cbsa[(cbsa['name']=='test')]
polygon = metro['geometry'].iloc[0]
G = ox.graph_from_polygon(polygon, network_type='walk')
i = ox.clean_intersections(G, tolerance=15, dead_ends=False)
print i

in this case it only returns

0    POINT (-122.2386546530941 37.80847450092825)
dtype: object

update: realize I need to project the graph with ox.project_graph(G) but this slows the script down a lot. Is there a way to only project the nodes and not the edges?

Error : No distribution matching

Good morning,

I tried to install OSMnx with pip on my Debian distro, but then I'd got this error :

Could not find a version that satisfies the requirement osmnx (from versions: 0.1a1.dev6, 0.1a1.dev5, 0.1a1.dev1, 0.1a1.dev4, 0.1a1.dev2, 0.1a1.dev7, 0.1a1.dev8, 0.1a1.dev4, 0.1a1.dev3, 0.1a1.dev9, 0.1a1.dev7, 0.1a1.dev11, 0.1a1.dev10, 0.1a1.dev10, 0.1a1.dev8, 0.1a1.dev6, 0.1a1.dev11, 0.1a1.dev9, 0.1a1, 0.1a1.dev3, 0.1a1.dev2, 0.1a1, 0.1a1.dev5)
Cleaning up...
No distributions matching the version for osmnx
Storing debug log for failure in /root/.pip/pip.log

(Geopandas is installed and works fine, I checked it before writing this issue)

Defining projection

Firstly please let me say that this is a great project!

Problem description (what did you do, what did you expect to happen, and what actually happened)

Trying to use the project functionality with a different datum.
currently the default is NAD83
{'datum': 'NAD83', 'ellps': 'GRS80', 'proj': 'utm', 'units': 'm', 'wktext': True, 'zone': 36}
I would like to project to a EPSG:32636 projection

Trying to run

places_prj = ox.project_gdf(places_il,  32636)
places_prj = ox.project_gdf(places_il,  '32636')
places_prj = ox.project_gdf(places_il,  'epsg:32636')

places_prj.crs always returns
{'init': 'epsg:4326'}

any ideas? any suggestion ?
should I try and extend osmnx/projection.py ? if so how would you do so?

What operating system, architecture, Python version, and OSMnx version are you using?

running on Win10

Complete list of your environment's packages and their versions (for example, run conda list or pip list then paste the output below)

python 3.5

bleach (1.5.0)
click (6.7)
click-plugins (1.0.3)
cligj (0.4.0)
colorama (0.3.7)
cycler (0.10.0)
decorator (4.0.11)
descartes (1.1.0)
entrypoints (0.2.2)
Fiona (1.7.1)
folium (0.2.1)
GDAL (2.1.2)
geopandas (0.2.1)
geopy (1.11.0)
html5lib (0.9999999)
imageio (1.6)
ipykernel (4.5.2)
ipython (5.1.0)
ipython-genutils (0.1.0)
ipywidgets (5.2.2)
Jinja2 (2.9.4)
jsonschema (2.5.1)
jupyter (1.0.0)
jupyter-client (4.4.0)
jupyter-console (5.0.0)
jupyter-core (4.2.1)
MarkupSafe (0.23)
matplotlib (2.0.0)
mistune (0.7.3)
moviepy (0.2.2.11)
munch (2.1.0)
nbconvert (5.1.1)
nbformat (4.2.0)
networkx (1.11)
notebook (4.3.1)
numpy (1.11.3)
olefile (0.44)
osmnx (0.2.2)
pandas (0.19.2)
pandocfilters (1.4.1)
pickleshare (0.7.4)
Pillow (4.0.0)
pip (9.0.1)
prompt-toolkit (1.0.9)
Pygments (2.1.3)
pyparsing (2.1.10)
pyproj (1.9.5.1)
python-dateutil (2.6.0)
pytz (2016.10)
pyzmq (16.0.2)
qtconsole (4.2.1)
requests (2.13.0)
Rtree (0.8.3)
setuptools (32.3.1)
Shapely (1.5.17)
simplegeneric (0.8.1)
simplekml (1.3.0)
six (1.10.0)
testpath (0.3)
tornado (4.4.2)
tqdm (4.11.0)
traitlets (4.3.1)
wcwidth (0.1.7)
wheel (0.30.0a0)
widgetsnbextension (1.2.6)
win-unicode-console (0.5)

plot_figure_ground: 'this isn't a TK application' (matplotlib)

for me, plot_figure_ground runs fine when using the ipython notebook in a browser,
but trying to run plot_figure_ground in a script on ubuntu 16.04 keeps throwing:

'this isn't a TK application':
...
tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/tkagg.py", line 30, in blit
id(data), colormode, id(bbox_array))
_tkinter.TclError: this isn't a Tk application

of course this seems to be an environment error, but i couldn't figure out how to solve this.
python-tk is installed via apt

any idea whats going wrong ?

What operating system, architecture, Python version, and OSMnx version are you using?

ubuntu 16.04, 64bit, python 2.7, osmnx 0.3.1

Complete list of your environment's packages and their versions (for example, run conda list or pip list then paste the output below)

# Paste the output of your Python packages and their versions here actionlib (1.11.7) adium-theme-ubuntu (0.3.4) appdirs (1.4.0) argcomplete (1.7.0) attrs (15.2.0) autobahn (0.10.3) backports-abc (0.5) backports.shutil-get-terminal-size (1.0.0) beautifulsoup4 (4.4.1) bleach (1.5.0) bondpy (1.7.18) buildozer (0.33.dev0) bzr (2.7.0) camera-calibration (1.12.19) camera-calibration-parsers (1.11.11) catkin (0.7.4) catkin-pkg (0.2.10) ccsm (0.9.12.2) certifi (2016.9.26) chardet (2.3.0) Cheetah (2.4.4) click (6.7) click-plugins (1.0.3) cligj (0.4.0) coloredlogs (5.2) compizconfig-python (0.9.12.2) configobj (5.0.6) configparser (3.5.0) cryptography (1.2.3) cv-bridge (1.12.3) cycler (0.9.0) Cython (0.21) decorator (4.0.6) defusedxml (0.4.1) descartes (1.1.0) diagnostic-analysis (1.8.10) diagnostic-common-diagnostics (1.8.10) diagnostic-updater (1.8.10) docutils (0.12) dynamic-reconfigure (1.5.46) ecdsa (0.13) empy (3.3.2) entrypoints (0.2.2) enum34 (1.1.2) executor (14.1) fasteners (0.14.1) Fiona (1.7.4) funcsigs (0.4) functools32 (3.2.3.post2) futures (3.0.5) gazebo-plugins (2.5.8) gazebo-ros (2.5.8) gencpp (0.5.4) geneus (2.2.5) genlisp (0.4.16) genmsg (0.5.8) gennodejs (1.0.3) genpy (0.6.3) geopandas (0.2.1) geopy (1.11.0) gyp (0.1) html5lib (0.999) httplib2 (0.9.1) humanfriendly (2.1) idna (2.0) image-geometry (1.12.3) interactive-markers (1.11.3) ipaddress (1.0.16) ipykernel (4.5.2) ipython (5.1.0) ipython-genutils (0.1.0) ipywidgets (5.2.2) Jinja2 (2.9.4) jsonschema (2.5.1) jupyter (1.0.0) jupyter-client (4.4.0) jupyter-console (5.0.0) jupyter-core (4.2.1) keyring (7.3) Kivy (1.9.1) laser-geometry (1.6.4) launchpadlib (1.10.3) lazr.restfulclient (0.13.4) lazr.uri (1.0.3) lxml (3.5.0) lz4 (0.7.0) MarkupSafe (0.23) matplotlib (1.5.1) meld (3.14.2) mercurial (3.7.3) message-filters (1.12.6) mistune (0.7.3) mock (1.3.0) monotonic (1.2) mpi4py (1.3.1) msgpack-python (0.4.6) MultipartPostHandler (0.1.0) munch (2.1.0) nbconvert (5.0.0) nbformat (4.2.0) ndg-httpsclient (0.4.0) netifaces (0.10.4) networkx (1.11) nose (1.3.7) notebook (4.3.1) numpy (1.11.0) oauth (1.0.1) oauthlib (2.0.1) osmnx (0.3.1) PAM (0.4.2) pandas (0.19.2) pandocfilters (1.4.1) paramiko (1.16.0) pathlib2 (2.2.0) pbr (1.8.0) pexpect (4.2.1) pickleshare (0.7.4) Pillow (3.1.2) pip (8.1.1) Pivy (0.5.0) pluginlib (1.10.4) proc (0.10.1) prompt-toolkit (1.0.9) property-manager (2.1) psutil (3.4.2) ptyprocess (0.5.1) py-notify (0.3.1) pyasn1 (0.1.9) pyasn1-modules (0.0.7) pycollada (0.4) pycrypto (2.6.1) pycurl (7.43.0) pydot (1.0.29) pyfreenect2 (0.0.0) Pygments (2.1) pygobject (3.20.0) pygpgme (0.3) PyOpenGL (3.0.2) pyOpenSSL (0.15.1) pyparsing (2.0.3) pyproj (1.9.5.1) pyserial (3.0.1) Pyste (0.9.10) python-apt (1.1.0b1) python-dateutil (2.4.2) python-escpos (2.2.0) python-networkmanager (1.2.1) python-qt-binding (0.3.1) python-snappy (0.5) pytz (2014.10) pyusb (1.0.0) PyYAML (3.11) pyzmq (15.2.0) qrcode (5.3) qt-dotgraph (0.3.3) qt-gui (0.3.3) qt-gui-cpp (0.3.3) qt-gui-py-common (0.3.3) qtconsole (4.2.1) requests (2.9.1) requests-oauthlib (0.7.0) resource-retriever (1.12.2) roman (2.0.0) rosbag (1.12.6) rosboost-cfg (1.13.4) rosclean (1.13.4) roscreate (1.13.4) rosdep (0.11.5) rosdistro (0.5.0) rosgraph (1.12.6) rosinstall (0.7.8) roslaunch (1.12.6) roslib (1.13.4) roslint (0.11.0) roslz4 (1.12.6) rosmake (1.13.4) rosmaster (1.12.6) rosmsg (1.12.6) rosnode (1.12.6) rosparam (1.12.6) rospkg (1.0.41) rospy (1.12.6) rosservice (1.12.6) rostest (1.12.6) rostopic (1.12.6) rosunit (1.13.4) roswtf (1.12.6) rqt-action (0.4.3) rqt-bag (0.4.3) rqt-bag-plugins (0.4.3) rqt-console (0.4.3) rqt-dep (0.4.3) rqt-graph (0.4.3) rqt-gui (0.3.1) rqt-gui-py (0.3.1) rqt-image-view (0.4.3) rqt-launch (0.4.3) rqt-logger-level (0.4.3) rqt-moveit (0.5.5) rqt-msg (0.4.3) rqt-nav-view (0.5.5) rqt-plot (0.4.3) rqt-pose-view (0.5.5) rqt-publisher (0.4.3) rqt-py-common (0.4.3) rqt-py-console (0.4.3) rqt-reconfigure (0.4.3) rqt-robot-dashboard (0.5.5) rqt-robot-monitor (0.5.5) rqt-robot-steering (0.5.5) rqt-runtime-monitor (0.5.5) rqt-rviz (0.5.5) rqt-service-caller (0.4.3) rqt-shell (0.4.3) rqt-srv (0.4.3) rqt-tf-tree (0.5.5) rqt-top (0.4.3) rqt-topic (0.4.3) rqt-web (0.4.3) Rtree (0.8.3) rviz (1.12.4) scandir (1.4) scipy (0.17.0) seaborn (0.7.1) SecretStorage (2.1.3) selenium (3.0.2) sensor-msgs (1.12.5) service-identity (16.0.0) setuptools (20.7.0) Shapely (1.5.17) simplegeneric (0.8.1) simplejson (3.8.1) singledispatch (3.4.0.3) six (1.10.0) smach (2.0.0) smach-ros (2.0.0) smclib (1.7.18) specto (0.3.1) stevedore (1.19.1) subprocess32 (3.2.7) terminado (0.6) testpath (0.3) tf (1.11.8) tf-conversions (1.11.8) tf2-geometry-msgs (0.5.13) tf2-kdl (0.5.13) tf2-py (0.5.13) tf2-ros (0.5.13) topic-tools (1.12.6) tornado (4.4.2) traitlets (4.3.1) trollius (2.0.1) tweepy (3.5.0) Twisted (16.0.0) txaio (1.0.0) Unidecode (0.4.19) unity-lens-photos (1.0) urlgrabber (3.9.1) urllib3 (1.13.1) vboxapi (1.0) vcstools (0.1.39) verboselogs (1.5) virtualenv (15.1.0) virtualenv-clone (0.2.6) virtualenvwrapper (4.7.2) wadllib (1.3.2) Wand (0.4.4) wcwidth (0.1.7) wheel (0.29.0) widgetsnbextension (1.2.6) wstool (0.1.13) wxPython (3.0.2.0) wxPython-common (3.0.2.0) xacro (1.11.1) youtube-dl (2016.2.22) zope.interface (4.1.3)

Code that reproduces the issue

place = 'portland'
point = (45.517309, -122.682138)
fig, ax = ox.plot_figure_ground(point=point, filename=place)

Method to weigh boulevards for intersection density calculations

Problem description (what did you do, what did you expect to happen, and what actually happened)

When calculating intersection density for an area, I would like to be able to identify 'boulevards' - or any sort of split roadway in the network - and either consolidate intersections at these locations into 1 node or reduce the 'weight' of the intersection such that all locations where a road crosses a boulevard only count as 1 intersection in the density calculation.

At first, I thought I could use the one-way attribute of edges in OSM networks to identify nodes that intersect with boulevards, and reduce their weight in the intersection density count by manually counting intersection density using a spatial intersection in geopandas. (see example 1 below, of downtown Merced, CA). However, this method would undercount valid one-way street intersections, such as those that exist when two one-way streets intersect (see example 2 of downtown San Francisco).

My next thought was that I could use the length attribute of edges to identify nodes that are shorter than a certain threshold and also connected to a one-way street. I then could either, reduce the weight applied to nodes that touch these edges based on how many one-way edges connect to it (two intersection boulevards should reduce intersection weight to 0.25, for example).

I'm wondering if anyone has already thought about a method for cleaning up intersection density count for the OSMnx library, and if code already exists within the repo for systematically addressing how to define an 'intersection' for the purpose of generating intersection density stats. Thanks!

Code that reproduces the issue

import osmnx as ox
%matplotlib inline

# Example 1: Downtown Merced, CA network with one boulevard
location_point = (37.3022, -120.4830)
G = ox.graph_from_point(location_point, distance=500)
# highlight one-way streets
ec = ['r' if data['oneway'] else 'b' for u, v, key, data in G.edges(keys=True, data=True)]
fig, ax = ox.plot_graph(G, node_color='w', node_edgecolor='k', node_size=5, node_zorder=3, 
                           edge_color=ec, edge_linewidth=1.5, edge_alpha=0.5)

image

# Example 2: Downtown San Francisco, CA network with many one-way streets
location_point = (37.782961, -122.409978)
G = ox.graph_from_point(location_point, distance=500)
# highlight one-way streets
ec = ['r' if data['oneway'] else 'b' for u, v, key, data in G.edges(keys=True, data=True)]
fig, ax = ox.plot_graph(G, node_color='w', node_edgecolor='k', node_size=5, node_zorder=3, 
                           edge_color=ec, edge_linewidth=1.5, edge_alpha=0.5)

image

egg_info issue

Hello! My colleague and I try both tried to install osmnx independently on both Python 2.7. and Python 3 and get the same error:

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-4UW2Zx/rtree/

Problem with accented characters

Hello,

With Python 2.7.x, if they are accented characters in the name of the edge, there is an unicode error when saving to shapefiles

lines 1998-1999

      for col in [c for c in gdf_edges.columns if not c == 'geometry']: `
      `     gdf_edges[col] = gdf_edges[col].fillna('').astype(str)`

The solution is to replace with unicode

gdf_edges[col] = gdf_edges[col].fillna('').astype('unicode')

Because, if I break down the script

place = 'Louvain-la-Neuve, Belgium'
G = ox.graph_from_place(place, network_type='drive')
G_projected = ox.project_graph(G)

import networkx as nx
G_save = G_projected.copy()
G_save = G_save.to_undirected()

edges = []
for u, v, key, data in G_save.edges(keys=True, data=True):
      # for each edge, add key and all attributes in data dict to the edge_details
      edge_details = {'key':key}
      for attr_key in data:
          #print attr_key, 
           edge_details[attr_key] = data[attr_key]
     edges.append(edge_details)

print edges[0]
{'name': u'Avenue Ath\xe9na', 'geometry': <shapely.geometry.linestring.LineString object at 0x11b02e050>, 'length': 26.273919709432, 'key': 0, 'oneway': True, 'highway':   
 edges[0]['name']
 u'Avenue Ath\xe9na'
 print edges[0]['name']
 Avenue Athéna

But

str(edges[0]['name']) 

gives an UnicodeEncodeError

pip version out of sync with readme

Hi. I was just checking out your package because it seemed quite useful. I can install it with conda and pip. However, the versions they install are not the ones you're using in your tutorials. As an example,

G = ox.graph_from_bbox([5.079162, 52.431064, 52.278174, 4.728759], type='drive')
ox.plot_graph(G)

errors with the following

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-33449b4aaa7e> in <module>()
----> 1 G = ox.graph_from_bbox([5.079162, 52.431064, 52.278174, 4.728759], type='drive')
      2 ox.plot_graph(G)

TypeError: graph_from_bbox() got an unexpected keyword argument 'type'

pip reported Successfully installed osmnx-0.1a1.

Intersections "strict/nonstrict"

Hello, I think it would be awesome to have a function/mode to "clean" intersections like this:

screen shot 2016-11-30 at 13 42 18

Since I make spatial inferences in neighbourhoods, I'm more interested on the real-world concept of intersection, rather that the OSM one. So it would be awesome to have the intersections with a buffer of n meters. (In the example this would count as "1" intersection)
What do you think?

'module' object has no attribute 'clean_intersections'

Loving working with OSMnx Geoff! Great tool. Ran into a problem in the example for 'Unify and clean-up intersections of divided roads'

I'm on Mac OS 10.12.3, using python 2.7.13, OSMnx 0.5

I can run the steps of the example without problem until this section:

# clean up the intersections and extract their xy coords
intersections = ox.clean_intersections(G_proj, tolerance=15, dead_ends=False)
points = np.array([point.xy for point in intersections])

which returns

AttributeError                            Traceback (most recent call last)
<ipython-input-3-c5c7cf0f7253> in <module>()
      1 # clean up the intersections and extract their xy coords
----> 2 intersections = ox.clean_intersections(G_proj, tolerance=15, dead_ends=False)
      3 points = np.array([point.xy for point in intersections])

AttributeError: 'module' object has no attribute 'clean_intersections'

TypeError: get() takes 1 positional argument but 2 were given

Good morning !

I've just installed OSMnx on my laptop running on Linux SMP Debian 3.16.7-ckt25-2 (kernel release 3.16.0-4-amd64), for both versions of Python.

Now I just tested this commands :

import osmnx as ox     # worked, no problem here
ox.plot_graph(ox.graph_from_place('Modena, Italy'))

But then, got these error :

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-0d3afc68e96a> in <module>()
----> 1 ox.plot_graph(ox.graph_from_place('Modena, Italy'))

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in graph_from_place(query, network_type, simplify, retain_all, truncate_by_edge, name, which_result, buffer_dist, timeout, memory, max_query_area_size, clean_periphery)
   1799     if isinstance(query, str) or isinstance(query, dict):
   1800         # if it is a string (place name) or dict (structured place query), then it is a single place
-> 1801         gdf_place = gdf_from_place(query, which_result=which_result, buffer_dist=buffer_dist)
   1802         name = query
   1803     elif isinstance(query, list):

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in gdf_from_place(query, gdf_name, which_result, buffer_dist)
    522 
    523     # get the data from OSM
--> 524     data = osm_polygon_download(query, limit=which_result)
    525     if len(data) >= which_result:
    526 

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in osm_polygon_download(query, limit, polygon_geojson, pause_duration)
    495 
    496     # request the URL, return the JSON
--> 497     response_json = nominatim_request(params=params, timeout=30)
    498     return response_json
    499 

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in nominatim_request(params, pause_duration, timeout, error_pause_duration)
    373         start_time = time.time()
    374         log('Requesting {} with timeout={}'.format(prepared_url, timeout))
--> 375         response = requests.get(url, params, timeout=timeout)
    376 
    377         # get the response size and the domain, log result

TypeError: get() takes 1 positional argument but 2 were given

Thanks in advance, and have a nice day !
EDIT : I'm working with an iPython notebook.

[Feature Suggestion] Smopy integration

Hi,

Kudos on great library! I've found it very useful.

For some recent routing work, I integrated smopy into a sort-of mangled version of your visualization code. The results are quite nice and permit use of other map tiles besides.

A sample:
image
[A georeferenced network w/ red one ways for (most of) Pittsburg, CA is rendered on top of the map. Also showing two routes in red and blue (alpha < 1 so purple where they match) + origin/destination points.]

I can refactor my implementation and submit a pull request from a fork if you'd like. However, I used an object-oriented approach with an earlier version of the master branch and suspect you would have your own way of implementing it. The general idea though is to initialize a smopy.Map instance w/ the coordinates of the network bounding box and call the show_mpl method on any existing matplotlib artist. The .to_map_pixels method on the smopy.Map instance must be used to plot any lines, points or other georeferenced data.

Figured this might be useful for you or other users, but not sure if this is the best place to provide this info. Feel free to close if not relevant.

Looking forward to future updates!

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

Incompatible library version

Ran installation instructions

import osmnx as ox
%matplotlib inline
ox.config(log_file=True, log_console=True, use_cache=True)

Received error

ImportError: dlopen(/Applications/anaconda/lib/python3.6/site-packages/fiona/ogrext.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: /Applications/anaconda/lib/libgdal.20.dylib
  Reason: Incompatible library version: libgdal.20.dylib requires version 45.0.0 or later, but libpng16.16.dylib provides version 44.0.0

I'm on a Mac, OS Sierra. Python 0.2.1

Last successful Terminal entry was...

[I 21:52:18.347 NotebookApp] Saving file at /Untitled1.ipynb
conda create --yes -c conda-forge -n OSMNX python=3.6 osmnx
source activate OSMNX
python -c 'import osmnx; print(osmnx.version)'
0.2.1

Problem installing on Ubuntu

Using Ubuntu 16.04.

I installed Anaconda and ran 'conda install -c ioos rtree=0.8.2'

Then used

pip install osmnx

Output:

Collecting osmnx Using cached osmnx-0.1b2-py2.py3-none-any.whl Requirement already satisfied: networkx>=1.11 in ./anaconda2/lib/python2.7/site-packages (from osmnx) Collecting shapely>=1.5 (from osmnx) Using cached Shapely-1.5.17.tar.gz Complete output from command python setup.py egg_info: Failed ``CDLL(libgeos_c.so.1)`` Failed ``CDLL(libgeos_c.so)
Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-zH46Y2/shapely/setup.py", line 38, in <module> from shapely._buildcfg import geos_version_string, geos_version, \ File "shapely/_buildcfg.py", line 167, in <module> fallbacks=['libgeos_c.so.1', 'libgeos_c.so']) File "shapely/_buildcfg.py", line 161, in load_dll libname, fallbacks or [])) OSError: Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-zH46Y2/shapely/

Any suggestions?

save_graph_shapefile no encoding option

Good morning !

I don't know if it's the right place to make this observation, I apologize by advance if it's not. Here's my point : I used OSMnx to display the street network of Liège (Belgium).

import osmnx as ox, matplotlib.pyplot as plt

liege_streets = ox.graph_from_place('Liège, Belgique', network_type='walk', retain_all=True)
liege_streets = ox.project_graph(liege_streets)

fig, ax = ox.plot_graph(liege_streets, fig_height=10, show=False, node_size=0, close=False, edge_color='#777777')

plt.show

This works perfectly fine, with this nice view of Liège :
liege

Then, I wanted to save this network in shapefile format. My goal was to achieve a merge with another lib', so I used the command :
ox.save_graph_shapefile(liege_streets, filename='liege_streets')

But there was this message :
WARNING:Fiona:CPLE_AppDefined in b"One or several characters couldn't be converted correctly from UTF-8 to ISO-8859-1.\nThis warning will not be emitted anymore."

I'm stuck because I would keep the UTF-8 encoding (because my other database is encoded with UTF-8). I read the code of save_graph_shapefile function and found no argument refering to the file's encoding. Do you think I must use Fiona library to do that ?

Thanks in advance and have a nice day !

AttributeError: 'AxesSubplot' object has no attribute 'set_facecolor'

What operating system, architecture, Python version, and OSMnx version are you using?

os 10.12 ,pycharm, python2.7, OSMnx 0.4

Code that reproduces the issue

raceback (most recent call last):
File "/Users/eden/PycharmProjects/examples/09-example-figure-ground.py", line 17, in
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', dpi=dpi)
File "/Library/Python/2.7/site-packages/osmnx/plot.py", line 706, in plot_figure_ground
show=show, save=save, close=close, filename=filename, file_format=file_format, dpi=dpi)
File "/Library/Python/2.7/site-packages/osmnx/plot.py", line 256, in plot_graph
ax.set_facecolor(bgcolor)
AttributeError: 'AxesSubplot' object has no attribute 'set_facecolor'

import osmnx as ox
from IPython.display import Image
#matplotlib inline
ox.config(log_file=True, log_console=True, use_cache=True)
# configure the inline image display
img_folder = 'images'
extension = 'png'
size = 350
dpi = 90

place = 'portland'
point = (45.517309, -122.682138)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)

Type Error with truncate_graph_polygon function

Problem description (what did you do, what did you expect to happen, and what actually happened)

My overall goal was to be able to calculate intersection density for several geometries that fall within a network, without having to make a separate API call to pull down a new network from OSM each time.

The general use case is to get network statistics (like intersection density) for geographies such as census blocks.

I found the truncate_graph_polygon function in the code base after a bit of digging. At first glance, it seemed like it would work well with my use case. I could iterate through census block geometries, call truncate_graph_polygon with the census block polygon as a parameter, get the stats for the census block, and then continue on to the next block.

However, the truncate_graph_polygon function produces an error, stemming from the intersect_index_quadrats function within it. It appears that iteration fails when the quadrat_cut_geometry function returns a Polygon, rather than a MultiPolygon. The link below shows where this error occurs in the codebase:

for poly in multipoly:

Below is an example that illustrates how this function fails, using city boundaries in Merced County, CA.

What operating system, architecture, Python version, and OSMnx version are you using?

  • Windows
  • Python 3.5
  • OSMnx 0.4.1

Complete list of your environment's packages and their versions (for example, run conda list or pip list then paste the output below)

_license 1.1 py35_1
alabaster 0.7.6 py35_0
anaconda 2.4.1 np110py35_0
anaconda-client 1.2.1 py35_0
appdirs 1.4.3
argcomplete 1.0.0 py35_1
astropy 1.0.6 np110py35_0
babel 2.1.1 py35_0
beautifulsoup4 4.4.1 py35_0
bitarray 0.8.1 py35_1
blaze-core 0.8.3 py35_0
bokeh 0.10.0 py35_0
boto 2.38.0 py35_0
bottleneck 1.0.0 np110py35_0
branca 0.2.0 py35_0 conda-forge
bzip2 1.0.6 vc14_2 [vc14]
cffi 1.9.1 py35_0
click 6.7 py35_0 conda-forge
click-plugins 1.0.3 py35_0 conda-forge
cligj 0.4.0 py35_0 conda-forge
clyent 1.2.0 py35_0
colorama 0.3.3 py35_0
comtypes 1.1.2 py35_0
conda 4.3.16 py35_0
conda-build 1.18.2 py35_0
conda-env 2.6.0 0
configobj 5.0.6 py35_0
console_shortcut 0.1.1 py35_1
cryptography 1.7.1 py35_0
curl 7.45.0 vc14_0 [vc14]
cycler 0.10.0 py35_0
cycler 0.10.0
cython 0.23.4 py35_0
cytoolz 0.7.4 py35_0
datashape 0.4.7 np110py35_1
decorator 4.0.11
decorator 4.0.6 py35_0
descartes 1.1.0 py35_0 conda-forge
docutils 0.12 py35_1
dynd-python 0.7.0 py35_0
et_xmlfile 1.0.1 py35_0
expat 2.1.0 vc14_2 [vc14] conda-forge
fastcache 1.0.2 py35_0
fiona 1.7.1 np110py35_1 conda-forge
flask 0.10.1 py35_1
folium 0.3.0 py35_0 conda-forge
freetype 2.6.3 vc14_1 [vc14] conda-forge
freexl 1.0.2 vc14_1 [vc14] conda-forge
gdal 2.1.2 np110py35_vc14_6 [vc14] conda-forge
geopandas 0.2.1 py35_3 conda-forge
geopy 1.11.0 py35_0 conda-forge
geos 3.5.1 vc14_1 [vc14] conda-forge
greenlet 0.4.9 py35_0
h5py 2.5.0 np110py35_4
hdf4 4.2.12 vc14_0 [vc14] conda-forge
hdf5 1.8.17 vc14_9 [vc14] conda-forge
icu 57.1 vc14_0 [vc14]
idna 2.0 py35_0
ipykernel 4.2.2 py35_0
ipython 4.0.3 py35_0
ipython-genutils 0.2.0
ipython-notebook 4.0.4 py35_3
ipython-qtconsole 4.0.1 py35_4
ipython_genutils 0.1.0 py35_0
ipywidgets 4.1.1 py35_0
itsdangerous 0.24 py35_0
jdcal 1.2 py35_1
jedi 0.9.0 py35_0
Jinja2 2.9.6
jinja2 2.8 py35_0
jpeg 9b vc14_0 [vc14] conda-forge
jsonschema 2.4.0 py35_0
jsonschema 2.6.0
jupyter 1.0.0 py35_1
jupyter-client 5.0.1
jupyter-core 4.3.0
jupyter_client 4.1.1 py35_0
jupyter_console 4.1.0 py35_0
jupyter_core 4.0.6 py35_0
kealib 1.4.6 vc14_3 [vc14] conda-forge
launcher 1.0.0 4
libdynd 0.7.0 0
libiconv 1.14 vc14_4 [vc14] conda-forge
libnetcdf 4.4.1.1 vc14_2 [vc14] conda-forge
libpng 1.6.28 vc14_0 [vc14] conda-forge
libpq 9.5.4 vc14_3 [vc14] conda-forge
libsodium 1.0.3 0
libspatialindex 1.8.5 vc14_1 [vc14] conda-forge
libspatialite 4.3.0a vc14_14 [vc14] conda-forge
libtiff 4.0.6 vc14_7 [vc14] conda-forge
libxml2 2.9.4 vc14_4 [vc14] conda-forge
llvmlite 0.8.0 py35_0
lxml 3.4.4 py35_0
markupsafe 0.23 py35_0
MarkupSafe 1.0
matplotlib 2.0.0 np112py35_0
matplotlib 1.5.1
menuinst 1.4.1 py35_0
mistune 0.7.1 py35_0
mkl 2017.0.1 0
msvc_runtime 1.0.1 vc14_0 [vc14]
multipledispatch 0.4.8 py35_0
munch 2.1.1 py35_0 conda-forge
nbconvert 4.1.0 py35_0
nbformat 4.3.0
nbformat 4.0.1 py35_0
networkx 1.10 py35_0
nltk 3.1 py35_0
node-webkit 0.10.1 0
nose 1.3.7 py35_0
notebook 4.4.1 py35_0
numba 0.22.1 np110py35_0
numexpr 2.6.2 np112py35_0
numpy 1.12.1 py35_0
numpy 1.11.0
odo 0.3.4 py35_0
openjpeg 2.1.2 vc14_1 [vc14] conda-forge
openpyxl 2.3.2 py35_0
openssl 1.0.2e vc14_1 [vc14]
osmnx 0.4.1 py35_0 conda-forge
packaging 16.8
pandas 0.18.1
pandas 0.19.2 np110py35_1 conda-forge
pandocfilters 1.4.1
path.py 8.1.2 py35_1
patsy 0.4.0 np110py35_0
pcre 8.39 vc14_0 [vc14] conda-forge
pep8 1.6.2 py35_0
pickleshare 0.5 py35_0
pillow 3.0.0 py35_1
pip 9.0.1
pip 8.1.2 py35_0
pip 8.1.2
plotly 1.9.5
ply 3.8 py35_0
proj4 4.9.3 vc14_3 [vc14] conda-forge
psutil 3.3.0 py35_0
psycopg2 2.6.1
psycopg2 2.6.2 py35_1 conda-forge
py 1.4.30 py35_0
pyasn1 0.1.9 py35_0
pycosat 0.6.1 py35_1
pycparser 2.14 py35_0
pycrypto 2.6.1 py35_3
pycurl 7.19.5.1 py35_1
pyflakes 1.0.0 py35_0
pygments 2.0.2 py35_0
pyopenssl 16.2.0 py35_0
pyparsing 2.0.3 py35_0
pyparsing 2.2.0
pyproj 1.9.5.1 py35_0 conda-forge
pyqt 5.6.0 py35_2
pyreadline 2.1 py35_0
pysal 1.13.0 py35_0 conda-forge
pytables 3.2.2 np110py35_1
pytest 2.8.1 py35_0
python 3.5.2 0
python-dateutil 2.6.0
python-dateutil 2.4.2 py35_0
pytz 2015.7 py35_0
pytz 2016.4
pywin32 219 py35_1
pyyaml 3.11 py35_4
pyzmq 15.2.0 py35_0
pyzmq 16.0.2
qt 5.6.2 vc14_3 [vc14]
qtconsole 4.1.1 py35_0
requests 2.10.0
requests 2.13.0 py35_0
rope 0.9.4 py35_1
rtree 0.8.3 py35_0 conda-forge
ruamel_yaml 0.11.14 py35_0
scikit-image 0.11.3 np110py35_0
scikit-learn 0.18.1 np112py35_1
scipy 0.19.0 np112py35_0
setuptools 26.1.1 py35_0
shapely 1.5.17 np110py35_2 conda-forge
simplegeneric 0.8.1 py35_0
sip 4.18 py35_0
six 1.10.0 py35_0
snowballstemmer 1.2.0 py35_0
sockjs-tornado 1.0.1 py35_0
sphinx 1.3.1 py35_0
sphinx_rtd_theme 0.1.7 py35_0
spyder 2.3.8 py35_0
spyder-app 2.3.8 py35_0
sqlalchemy 1.0.9 py35_0
sqlite 3.13.0 vc14_0 [vc14] conda-forge
statsmodels 0.6.1 np110py35_0
sympy 0.7.6.1 py35_0
tk 8.5.18 vc14_0 [vc14]
toolz 0.7.4 py35_0
tornado 4.4.3
tornado 4.4.2 py35_0
traitlets 4.3.2
traitlets 4.1.0 py35_0
ujson 1.33 py35_0
unicodecsv 0.14.1 py35_0
vc 14 0 conda-forge
vincent 0.4.4 py35_0 conda-forge
vs2015_runtime 14.0.25123 0
werkzeug 0.11.2 py35_0
wheel 0.29.0 py35_0
xerces-c 3.1.4 vc14_2 [vc14] conda-forge
xlrd 0.9.4 py35_0
xlsxwriter 0.7.7 py35_0
xlwings 0.5.0 py35_0
xlwt 1.0.0 py35_0
zeromq 4.1.3 vc14_1 [vc14]
zlib 1.2.8 vc14_2 [vc14]

Code that reproduces the issue

import osmnx as ox
# Import Merced County network from OSM
G = ox.graph_from_place('Merced County, California, USA', network_type='drive_service')
G = ox.project_graph(G)

# Import boundary for some cities in Merced County from OSM
place_names = ['Merced, California, USA', 
               'Atwater, California, USA',
               'Livingston, California, USA']
merced_cities = ox.gdf_from_places(place_names)
merced_cities = ox.project_gdf(merced_cities)

# get polygon for city of Merced
merced_polygon = merced_cities['geometry'].iloc[0]

# Truncate graph to the polygon shape
g_sample = ox.truncate_graph_polygon(G, merced_polygon, retain_all=False, truncate_by_edge=False)

# This produces the following error: TypeError: 'Polygon' object is not iterable

Raise TypeError with networkx latest version ''2.0.dev_20170110215719'

Hello Geoff !
I am currently testing osmnx to figure out how useful it is for my purposes. First of all, I would like to compliment you, it is a terrific library with great features, thank you for this work.
However, I would like to bring to your attention that it currently does not work together with networkx 2 and their changes to work to an iterator reporting API.
https://networkx.github.io/documentation/development/reference/release_2.0.html.

Example:

G5 = ox.graph_from_place('Manhattan, New York City, New York, USA')
G5_projected = ox.project_graph(G5)
fig, ax = ox.plot_graph(G5_projected)

TypeError Traceback (most recent call last)
in ()
1 # # create the street network within the region of Chittagong
----> 2 G5 = ox.graph_from_place('Chittagong, Chittagong, Bangladesh')
3 G5_projected = ox.project_graph(G5)
4 fig, ax = ox.plot_graph(G5_projected)

/home/philipp/anaconda3/envs/env_geotiff/lib/python2.7/site-packages/osmnx/osmnx.pyc in graph_from_place(query, network_type, simplify, retain_all, truncate_by_edge, name, which_result, buffer_dist, timeout, memory, max_query_area_size, clean_periphery)
1814 # create graph using this polygon(s) geometry
1815 G = graph_from_polygon(polygon, network_type=network_type, simplify=simplify, retain_all=retain_all,
-> 1816 truncate_by_edge=truncate_by_edge, name=name, timeout=timeout, memory=memory, max_query_area_size=max_query_area_size, clean_periphery=clean_periphery)
1817
1818 log('graph_from_place() returning graph with {:,} nodes and {:,} edges'.format(len(G.nodes()), len(G.edges())))

/home/philipp/anaconda3/envs/env_geotiff/lib/python2.7/site-packages/osmnx/osmnx.pyc in graph_from_polygon(polygon, network_type, simplify, retain_all, truncate_by_edge, name, timeout, memory, max_query_area_size, clean_periphery)
1740 # get the network data from OSM, create the buffered graph, then truncate it to the buffered polygon
1741 response_jsons = osm_net_download(polygon=polygon_buffered, network_type=network_type, timeout=timeout, memory=memory, max_query_area_size=max_query_area_size)
-> 1742 G_buffered = create_graph(response_jsons, name=name, retain_all=True, network_type=network_type)
1743 G_buffered = truncate_graph_polygon(G_buffered, polygon_buffered, retain_all=True, truncate_by_edge=truncate_by_edge)
1744

/home/philipp/anaconda3/envs/env_geotiff/lib/python2.7/site-packages/osmnx/osmnx.pyc in create_graph(response_jsons, name, retain_all, network_type)
1499 G = get_largest_component(G)
1500
-> 1501 log('Created graph with {:,} nodes and {:,} edges in {:,.2f} seconds'.format(len(G.nodes()), len(G.edges()), time.time()-start_time))
1502
1503 # add length (great circle distance between nodes) attribute to each edge to use as weight

TypeError: object of type 'generator' has no len()

Trouble installing on OSX

Your library looks amazing and I am excited to try it out. Unfortunately, the installation procedure produced an import error (included below).

Here were the exact steps I followed:

  1. Uninstalled anaconda.
  2. Reinstalled anaconda (Anaconda3-4.2.0-MacOSX-x86_64.pkg)
  3. Ran conda install -c conda-forge osmnx in the terminal
  4. Launched a Jupyter notebook (jupyter notebook)
  5. Ran import osmnx as ox

System info:
OS X El Capitan v10.11.6
MacBook Pro

Complete stack trace:

ImportError Traceback (most recent call last)
in ()
----> 1 import osmnx as ox

/Users/user/anaconda/lib/python3.5/site-packages/osmnx/init.py in ()
6 ###################################################################################################
7
----> 8 from .core import *
9 from .plot import *
10 from .projection import *

/Users/user/anaconda/lib/python3.5/site-packages/osmnx/core.py in ()
18 import numpy as np
19 import pandas as pd
---> 20 import geopandas as gpd
21 import networkx as nx
22

/Users/user/anaconda/lib/python3.5/site-packages/geopandas/init.py in ()
2 from geopandas.geodataframe import GeoDataFrame
3
----> 4 from geopandas.io.file import read_file
5 from geopandas.io.sql import read_postgis
6 from geopandas.tools import sjoin

/Users/user/anaconda/lib/python3.5/site-packages/geopandas/io/file.py in ()
1 import os
2
----> 3 import fiona
4 import numpy as np
5 from shapely.geometry import mapping

/Users/user/anaconda/lib/python3.5/site-packages/fiona/init.py in ()
67 from six import string_types
68
---> 69 from fiona.collection import Collection, BytesCollection, vsi_path
70 from fiona._drivers import driver_count, GDALEnv
71 from fiona.drvsupport import supported_drivers

/Users/user/anaconda/lib/python3.5/site-packages/fiona/collection.py in ()
6
7 from fiona import compat
----> 8 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
9 from fiona.ogrext import Session, WritingSession
10 from fiona.ogrext import (

ImportError: dlopen(/Users/user/anaconda/lib/python3.5/site-packages/fiona/ogrext.cpython-35m-darwin.so, 2): Library not loaded: @rpath/libnetcdf.11.dylib
Referenced from: /Users/user/anaconda/lib/libgdal.20.dylib
Reason: Incompatible library version: libgdal.20.dylib requires version 12.0.0 or later, but libnetcdf.11.dylib provides version 11.0.0

ox.plot_graph() fails with attribute error

I noticed now when upgrading osmnx that suddenly: ox.plot_graph() fails with attribute error.
The problematic function is in line 261 of plot.py: "ax.set_facecolor()".

Code looks like this:


# create the figure and axis
fig, ax = plt.subplots(figsize=(fig_width, fig_height), facecolor=bgcolor)
ax.set_facecolor(bgcolor)

Produces the following error:
AttributeError: 'AxesSubplot' object has no attribute 'set_facecolor'

For now I just outcommented the problematic, which seem to have fixed it.
Problem occurs on ubuntu and osmnx version - osmnx-0.4-py27, today installed from conda forge.

Before in older osmnx version it was working well with:

    # create the figure and axis
    fig, ax = plt.subplots(figsize=(fig_width, fig_height), facecolor=bgcolor)
    ax.set_axis_bgcolor(bgcolor)

But the set_axis_bgcolor function was deprecated in version 2.0

Saved svg files are broken

Hey Geoff, you did an amazing work on osmnx.
But I've trouble when I want to save shapes or networks as a svg file.
I've did:

import osmnx as ox
#matplotlib inline
ox.config(log_file=True, log_console=True, use_cache=True)
G = ox.graph_from_place('Hamburg, Germany', network_type='drive_service', simplify=False)
G_projected = ox.project_graph(G)
fig, ax = ox.plot_graph(G_projected, fig_height=30, node_size=0, edge_linewidth=0.5, save=True, file_format='svg', filename='Hamburg')

After running it the last line says „Saved the figure to disk in 48.39 seconds"
And when I'm going to open it, Illustrator prompting an error message that the file seems to be broken.
Am I doing something wrong?

I'm running osmnx on Mac OS El Capitan with Python 3.5

unhashable type: 'LineString'

While I was trying to repeat this: https://github.com/gboeing/osmnx/blob/master/examples/04-example-simplify-network.ipynb, I have this issue:

import osmnx as ox
G = ox.graph_from_place('caneva, Italy')
ox.plot_graph(G, node_color='b', node_zorder=3)
# simplify the network
G2 = G.copy()
G2 = ox.simplify_graph(G2)

result:

TypeError                                 Traceback (most recent call last)
<ipython-input-61-b9e77563d9b6> in <module>()
      1 # simplify the network
      2 G2 = G.copy()
----> 3 G2 = ox.simplify_graph(G2)

/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/osmnx/osmnx.py in simplify_graph(G_, strict)
   2373         for key in edge_attributes:
   2374             # don't touch the length attribute, we'll sum it at the end
-> 2375             if len(set(edge_attributes[key])) == 1 and not key == 'length':
   2376                 # if there's only 1 unique value in this attribute list, consolidate it to the single value (the zero-th)
   2377                 edge_attributes[key] = edge_attributes[key][0]

TypeError: unhashable type: 'LineString'

Python3, shapely 1.6.

get_nearest_node and shortest_path performance issue

I'm trying to calculate routes from thousands of points.
Running the get_nearest_node and shortest_path on the following network takes a long time.

{
	'circuity_avg' : 1.084601551622338,
	'count_intersections' : 58456,
	'edge_density_km' : None,
	'edge_length_avg' : 119.35486740722354,
	'edge_length_total' : 19018004.572667,
	'intersection_density_km' : None,
	'k_avg' : 4.536693003060716,
	'm' : 159340,
	'n' : 70245,
	'node_density_km' : None,
	'self_loop_proportion' : 0.004022844232458893,
	'street_density_km' : None,
	'street_length_avg' : 123.93589363482089,
	'street_length_total' : 12220326.984180609,
	'street_segments_count' : 98602,
	'streets_per_node_avg' : 2.80183642963912,
	'streets_per_node_counts' : {
		0 : 0,
		1 : 11789,
		2 : 499,
		3 : 48094,
		4 : 9584,
		5 : 265,
		6 : 13,
		7 : 1
	},
	'streets_per_node_proportion' : {
		0 : 0.0,
		1 : 0.16782689159370773,
		2 : 0.007103708448999929,
		3 : 0.6846608299523098,
		4 : 0.13643675706455977,
		5 : 0.003772510498967898,
		6 : 0.00018506655277955727,
		7 : 1.4235888675350559e-05
	}
}

In order to increase the performance of the function I think the function should select a subset of nodes (based on some parameter), there after run the great_circle() method.
I'm thinking of using nx.ego_graph - do you think this is a good direction?

In the meantime since I have some points that repeat themselves I've used some caching techniques. Do you think it is relevant to add to the core.py?

from functools import lru_cache

@lru_cache(maxsize=None)
def get_nearst_node_(graph, coordinate):
    return ox.get_nearest_node(graph, coordinate)

@lru_cache(maxsize=None)
def shortest_path_(graph, origin_node, destination_node):
    return nx.shortest_path(graph, origin_node, destination_node)

Include turn restrictions?

Great tool! For modelling routes, does this module incorporate turn_restrictions? In OSM, it is modeled as relations.

Add to plot_figure_ground the possibility to get a multidigraph parameter

Similar to the other plot functions I thought to add a multidigraph parameter.

def plot_figure_ground(G, address=None, point=None, dist=805, network_type='drive_service',
                       street_widths=None, default_width=4, fig_length=8, edge_color='w', bgcolor='#333333',
                       filename=None, file_format='png', show=False, save=True, close=True, dpi=300):

Sending a PR

Certificate verify failed

Hello all,

I am new here thus excuse me if I am asking something simple.

I have been trying to get osmnx going with that:
import osmnx as ox
city = ox.gdf_from_place('Berkeley, CA')
ox.plot_shape(ox.project_gdf(city))

But I am getting this output error all the time:
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

Please could you suggest any solutions cause the ones I have seen so far are not working.

Thanks a lot.

ValueError: Geometry must be a shapely Polygon or MultiPolygon

If we run this code:

import osmnx as ox
ox.config(log_console=True)
G = ox.graph_from_place('Baltimore, Maryland, USA', network_type='drive')

We get this error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-afb511cf7347> in <module>()
      1 import osmnx as ox
      2 ox.config(log_console=True)
----> 3 G = ox.graph_from_place('Baltimore, Maryland, USA', network_type='drive')

C:\Anaconda\lib\site-packages\osmnx\osmnx.py in graph_from_place(query, network_type, simplify, retain_all, truncate_by_edge, name, which_result, buffer_dist, timeout, memory, max_query_area_size, clean_periphery)
   1815     # create graph using this polygon(s) geometry
   1816     G = graph_from_polygon(polygon, network_type=network_type, simplify=simplify, retain_all=retain_all, 
-> 1817                            truncate_by_edge=truncate_by_edge, name=name, timeout=timeout, memory=memory, max_query_area_size=max_query_area_size, clean_periphery=clean_periphery)
   1818 
   1819     log('graph_from_place() returning graph with {:,} nodes and {:,} edges'.format(len(G.nodes()), len(G.edges())))

C:\Anaconda\lib\site-packages\osmnx\osmnx.py in graph_from_polygon(polygon, network_type, simplify, retain_all, truncate_by_edge, name, timeout, memory, max_query_area_size, clean_periphery)
   1730         raise ValueError('Shape does not have a valid geometry')
   1731     if not isinstance(polygon, (Polygon, MultiPolygon)):
-> 1732         raise ValueError('Geometry must be a shapely Polygon or MultiPolygon')
   1733 
   1734     if clean_periphery and simplify:

ValueError: Geometry must be a shapely Polygon or MultiPolygon

Windows 64bit Python 2.7 RTree Error

Running through the example of:

import osmnx as ox
G = ox.graph_from_place('Berkeley, California', network_type='drive')
stats = ox.basic_stats(G)
ox.plot_graph(G)

I get an error when running in a 64bit version. I tried both a OSGeo4W python install and stand alone with the same resulting error message:

Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32
>>> import osmnx as ox
Backend TkAgg is interactive backend. Turning interactive mode on.
>>> G = ox.graph_from_place('Berkeley, California', network_type='drive')
C:\OSGeo4W64\apps\Python27\lib\site-packages\requests\packages\urllib3\util\ssl_.py:334: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  SNIMissingWarning
C:\OSGeo4W64\apps\Python27\lib\site-packages\requests\packages\urllib3\util\ssl_.py:132: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\OSGeo4W64\apps\Python27\lib\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 "C:\OSGeo4W64\apps\Python27\lib\site-packages\osmnx\osmnx.py", line 1742, in graph_from_polygon
    G_buffered = truncate_graph_polygon(G_buffered, polygon_buffered, retain_all=True, truncate_by_edge=truncate_by_edge)
  File "C:\OSGeo4W64\apps\Python27\lib\site-packages\osmnx\osmnx.py", line 1306, in truncate_graph_polygon
    points_within_geometry = intersect_index_quadrats(gdf_nodes, polygon)
  File "C:\OSGeo4W64\apps\Python27\lib\site-packages\osmnx\osmnx.py", line 1256, in intersect_index_quadrats
    sindex = gdf['geometry'].sindex
  File "C:\OSGeo4W64\apps\Python27\lib\site-packages\geopandas\base.py", line 292, in sindex
    self._generate_sindex()
  File "C:\OSGeo4W64\apps\Python27\lib\site-packages\geopandas\base.py", line 80, in _generate_sindex
    self._sindex = SpatialIndex(stream)
  File "C:\OSGeo4W64\apps\Python27\lib\site-packages\geopandas\sindex.py", line 16, in __init__
    RTreeIndex.__init__(self, *args)
  File "C:\OSGeo4W64\apps\Python27\lib\site-packages\rtree\index.py", line 179, in __init__
    self.properties = kwargs.get('properties', Property())
  File "C:\OSGeo4W64\apps\Python27\lib\site-packages\rtree\index.py", line 906, in __init__
    handle = PropertyHandle()
  File "C:\OSGeo4W64\apps\Python27\lib\site-packages\rtree\index.py", line 848, in __init__
    self._ptr = self._create(*args, **kwargs)
WindowsError: exception: access violation reading 0x0000000000224000

Exception AttributeError: "'PropertyHandle' object has no attribute '_ptr'" in <bound method PropertyHandle.__del__ of <rtree.index.PropertyHandle object at 0x0000000021A72DD8>> ignored

Works great in 32 bit version.

Install error with ValueError: unsupported format character 'B' (0x42) at index 238

If you're having trouble with OSMnx, first search the previously opened issues to see if the problem has already been noted. If not, fill in the template below. You can delete any sections that don't apply.

Problem description (what did you do, what did you expect to happen, and what actually happened)

What operating system, architecture, Python version, and OSMnx version are you using?

Complete list of your environment's packages and their versions (for example, run conda list or pip list then paste the output below)

# Paste the output of your Python packages and their versions here, between these two "details" tags I have installed Anaconda with Python 2.7 in Mac OSX system. Using `conda install -c conda-forge osmnx`, the errors show like this:

Code that reproduces the issue

    Traceback (most recent call last):
      File "/Users/HYF/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 479, in conda_exception_handler
        return_value = func(*args, **kwargs)
      File "/Users/HYF/anaconda/lib/python2.7/site-packages/conda/cli/main.py", line 145, in _main
        exit_code = args.func(args, p)
      File "/Users/HYF/anaconda/lib/python2.7/site-packages/conda/cli/main_install.py", line 80, in execute
        install(args, parser, 'install')
      File "/Users/HYF/anaconda/lib/python2.7/site-packages/conda/cli/install.py", line 420, in install
        raise CondaRuntimeError('RuntimeError: %s' % e)
      File "/Users/HYF/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 45, in __str__
        return text_type(self.message % self._kwargs)
    ValueError: unsupported format character 'B' (0x42) at index 238

Rtree and a missing libspatialindex_c library file

Problem description (what did you do, what did you expect to happen, and what actually happened)

Importing osmnx on the Python REPL indicates a missing libspatialindex_c library file.

What operating system, architecture, Python version, and OSMnx version are you using?

Mac OS X 10.10.5 Yosemite, Python 2.7.12. osmnx 0.4.1

Code that reproduces the issue

>> import osmnx as ox
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/osmnx/__init__.py", line 8, in <module>
    from .core import *
  File "/usr/local/lib/python2.7/site-packages/osmnx/core.py", line 20, in <module>
    import geopandas as gpd
  File "/usr/local/lib/python2.7/site-packages/geopandas/__init__.py", line 1, in <module>
    from geopandas.geoseries import GeoSeries
  File "/usr/local/lib/python2.7/site-packages/geopandas/geoseries.py", line 16, in <module>
    from geopandas.base import GeoPandasBase
  File "/usr/local/lib/python2.7/site-packages/geopandas/base.py", line 15, in <module>
    from rtree.core import RTreeError
  File "/usr/local/lib/python2.7/site-packages/rtree/__init__.py", line 1, in <module>
    from .index import Rtree
  File "/usr/local/lib/python2.7/site-packages/rtree/index.py", line 5, in <module>
    from . import core
  File "/usr/local/lib/python2.7/site-packages/rtree/core.py", line 125, in <module>
    raise OSError("Could not find libspatialindex_c library file")
OSError: Could not find libspatialindex_c library file

The solution was described in this blogpost: brew install spatialindex.

This issue may be closed as I created this issue purely for documentation purposes.

Some trouble with graph serialization

Hi!
It seams graph created with osmnx (v. 1.11) are not supported by some NetworkX serializers (at least graphml and gml), for example I tried:

import osmnx as ox
from networkx.readwrite import write_graphml
bbox_nsew = (44.5154836411, 44.4930257589, 11.3460649038, 11.3240450721,)
G = ox.graph_from_bbox(*bbox_nsew, simplify=False)
write_graphml(G, "mygraph.xml")

obtaining to raise this exception:

Traceback (most recent call last):
File "iNetworkX_unittest.py", line 45, in setUp
write_graphml(G, "mygraph.xml")
File "", line 2, in write_graphml
File "/usr/local/lib/python2.7/dist-packages/networkx/utils/decorators.py", line 220, in _open_file
result = func(*new_args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 82, in write_graphml
writer.add_graph_element(G)
File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 349, in add_graph_element
self.add_attributes("graph", graph_element, data, default)
File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 300, in add_attributes
scope=scope, default=default_value)
File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 288, in add_data
'%s as data values.'%element_type)
NetworkXError: GraphML writer does not support <type 'dict'> as data values.

I would like to save raw data for successive elaborations without downloading data again... how is it possible?

Thank you very mutch
Cheers
Manuele

ImportError

Sorry if this is a simple problem, I'm not really a coder...

Problem description (what did you do, what did you expect to happen, and what actually happened)

Installed Anaconda OS X Graphical Installer, left everything at default and ran

conda install -c conda-forge osmnx

I then opened Spyder and pasted in the following example code from the website:

import osmnx as ox
ox.plot_graph(ox.graph_from_place('Modena, Italy'))

When I run the code (as well as other examples) I keep getting this ImportError:

ImportError: dlopen(//anaconda/lib/python3.5/site-packages/fiona/ogrext.cpython-35m-darwin.so, 2): Library not loaded: @rpath/libnetcdf.11.dylib
  Referenced from: //anaconda/lib/libgdal.20.dylib
  Reason: Incompatible library version: libgdal.20.dylib requires version 12.0.0 or later, but libnetcdf.11.dylib provides version 11.0.0

What operating system, architecture, Python version, and OSMnx version are you using?

OS X Sierra (10.12.2), Anaconda 4.2.0, Python 3.5, OSMnx 0.2.2

Complete list of your environment's packages and their versions (for example, run conda list or pip list then paste the output below)

appnope 0.1.0 py35_0
click 6.6 py35_1 conda-forge
click-plugins 1.0.3 py35_0 conda-forge
cligj 0.4.0 py35_0 conda-forge
curl 7.52.1 0 conda-forge
cycler 0.10.0 py35_0 conda-forge
decorator 4.0.11 py35_0
descartes 1.1.0 py35_0 conda-forge
entrypoints 0.2.2 py35_0
fiona 1.7.2 np111py35_0 conda-forge
freetype 2.6.3 1 conda-forge
gdal 2.1.0 py35_0
geopandas 0.2.1 py35_3 conda-forge
geopy 1.11.0 py35_0 conda-forge
geos 3.5.1 1 conda-forge
geotiff 1.4.1 0
hdf4 4.2.12 0 conda-forge
hdf5 1.8.17 9 conda-forge
icu 54.1 0
ipykernel 4.5.2 py35_0
ipython 5.1.0 py35_1
ipython_genutils 0.1.0 py35_0
ipywidgets 5.2.2 py35_1
jinja2 2.9.4 py35_0
jpeg 9b 0 conda-forge
jsonschema 2.5.1 py35_0
jupyter 1.0.0 py35_3
jupyter_client 4.4.0 py35_0
jupyter_console 5.0.0 py35_0
jupyter_core 4.2.1 py35_0
kealib 1.4.6 3 conda-forge
libgdal 2.1.0 0
libgfortran 3.0.0 0 conda-forge
libnetcdf 4.4.1 0 conda-forge
libpng 1.6.28 0 conda-forge
libpq 9.5.4 3 conda-forge
libspatialindex 1.8.5 1 conda-forge
libtiff 4.0.6 7 conda-forge
markupsafe 0.23 py35_2
matplotlib 2.0.0 np111py35_1 conda-forge
mistune 0.7.3 py35_1
mkl 2017.0.1 0
munch 2.1.0 py35_0 conda-forge
nbconvert 4.2.0 py35_0
nbformat 4.2.0 py35_0
networkx 1.11 py35_0 conda-forge
notebook 4.3.1 py35_0
numpy 1.11.3 py35_0
openssl 1.0.2k 0
osmnx 0.2.2 py35_0 conda-forge
pandas 0.19.2 np111py35_1 conda-forge
path.py 10.0 py35_0
pexpect 4.2.1 py35_0
pickleshare 0.7.4 py35_0
pip 9.0.1 py35_1
proj4 4.9.2 0
prompt_toolkit 1.0.9 py35_0
psycopg2 2.6.2 py35_1 conda-forge
ptyprocess 0.5.1 py35_0
pygments 2.1.3 py35_0
pyparsing 2.1.10 py35_0 conda-forge
pyproj 1.9.5.1 py35_0 conda-forge
pyqt 5.6.0 py35_2
pysal 1.13.0 py35_0 conda-forge
python 3.5.2 0
python-dateutil 2.6.0 py35_0 conda-forge
pytz 2016.10 py35_0 conda-forge
pyzmq 16.0.2 py35_0
qt 5.6.2 0
qtconsole 4.2.1 py35_1
readline 6.2 2
requests 2.13.0 py35_0 conda-forge
rtree 0.8.3 py35_0 conda-forge
scipy 0.18.1 np111py35_1
setuptools 27.2.0 py35_0
shapely 1.5.17 np111py35_2 conda-forge
simplegeneric 0.8.1 py35_1
sip 4.18 py35_0
six 1.10.0 py35_0
sqlalchemy 1.1.5 py35_0 conda-forge
sqlite 3.13.0 0
terminado 0.6 py35_0
tk 8.5.18 0
tornado 4.4.2 py35_0
traitlets 4.3.1 py35_0
wcwidth 0.1.7 py35_0
wheel 0.29.0 py35_0
widgetsnbextension 1.2.6 py35_0
xerces-c 3.1.4 0
xz 5.2.2 1
zlib 1.2.8 3

Code that reproduces the issue

I've used this example code, as well as other examples given in the docs.

import osmnx as ox
ox.plot_graph(ox.graph_from_place('Modena, Italy'))

use of osmnx for local OSM files

Thanks a lot for your great and neat work @gboeing
What am I writing is not an issue, so I hope it is OK to post it here.
I am wondering if it is possible to use local sources of OSM instead of downloading from OSM server?
What I am interested is to take .png pics (e.g. only roads or only roads and buildings) of up to million locations in different continents.
So far, I am using static API of Mapbox with a certain styled map.
I have more info about my project here
Thanks in advance.
Best
Vahid

load_graphml: data['oneway'] is always True

Hi,

I have noticed one problem with load_graphml.
data['one_way'] is always True in the loaded graph.

The error comes from line 218 from save_load.py

data['oneway'] = bool(data['oneway'])

should be replaced with

data['oneway'] = ast.literal_eval(data['oneway'])

because non-empty strings are always True in python.

graph_from_place AttributeError

Hey!

I'm using Python 3.5.2 on Ubuntu. When using the graph_from_place I get the following error message. I use Anaconda with all packages installed from the 'conda-forge' channel. The issue remains even when changing to Python 2 or using the newest version from github installed through pip and across machines.

>>> import osmnx as ox
>>> G = ox.graph_from_place('Piedmont, CA, USA', network_type='drive')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/andreasbn/anaconda3/envs/python2/lib/python2.7/site-packages/osmnx/osmnx.py", line 1824, 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/andreasbn/anaconda3/envs/python2/lib/python2.7/site-packages/osmnx/osmnx.py", line 1751, in graph_from_polygon
    G_buffered = truncate_graph_polygon(G_buffered, polygon_buffered, retain_all=True, truncate_by_edge=truncate_by_edge)
  File "/home/andreasbn/anaconda3/envs/python2/lib/python2.7/site-packages/osmnx/osmnx.py", line 1306, in truncate_graph_polygon
    points_within_geometry = intersect_index_quadrats(gdf_nodes, polygon)
  File "/home/andreasbn/anaconda3/envs/python2/lib/python2.7/site-packages/osmnx/osmnx.py", line 1268, in intersect_index_quadrats
    possible_matches_index = list(sindex.intersection(poly.bounds))
AttributeError: 'NoneType' object has no attribute 'intersection'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.