-
Notifications
You must be signed in to change notification settings - Fork 41
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
osm.get_network() returning None type after one use #180
Comments
UPDATE I have since been provided with a new Ubuntu laptop, thus a fresh install and the problems still persist. As can be seen below - I can request and plot the initial network request I make ( I can request and plot the intitial network I request however an subsequant requests return a NoneType, however I am still able to perform this analysis within google colab with no issues. Running my script (courtesy of reprexpy) import pyrosm
import osmnx
#import geemap
import folium
print('Hello World!')
#> Hello World!
# View available places for analysis
available_places = pyrosm.data.available
available_places.keys()
#> dict_keys(['test_data', 'regions', 'subregions', 'cities'])
'Leeds' in available_places['cities']
#> True
# Gets data from pyrosm providers (BBBike or Geofabrik) and stores in /temp directory - file can be saved to a user specified
# location with additional arguments i.e. get_data(place_name, directory='Desired location to save file')
place_name = 'Leeds'
file_path = pyrosm.get_data(place_name)
print('Data downloaded to:', file_path)
#> Data downloaded to: /tmp/pyrosm/Leeds.osm.pbf
# Initialises the OSM object that parses .osm.pbf files
osm = pyrosm.OSM(file_path)
print('osm type:', type(osm))
#> osm type: <class 'pyrosm.pyrosm.OSM'>
# Obtaining the total network for 'Leeds'
leeds_total_network = osm.get_network(network_type = 'all')
print('Variable shape:',leeds_total_network.shape, 'and type:', type(leeds_total_network))
#> Variable shape: (135779, 39) and type: <class 'geopandas.geodataframe.GeoDataFrame'>
# View all columns of data returned
keys = leeds_total_network.columns
print(keys)
#> Index(['access', 'area', 'bicycle', 'bicycle_road', 'bridge', 'busway',
#> 'cycleway', 'est_width', 'foot', 'footway', 'highway', 'int_ref',
#> 'junction', 'lanes', 'lit', 'maxspeed', 'motorcar', 'motor_vehicle',
#> 'name', 'oneway', 'overtaking', 'psv', 'ref', 'service', 'segregated',
#> 'sidewalk', 'smoothness', 'surface', 'tracktype', 'tunnel', 'turn',
#> 'width', 'id', 'timestamp', 'version', 'tags', 'osm_type', 'geometry',
#> 'length'],
#> dtype='object')
# Plotting the total network for Leeds
leeds_total_network.plot()
#> <AxesSubplot:>
# Plot the dirving network of Leeds
leeds_driving_network = osm.get_network(network_type='driving')
leeds_driving_network.plot()
#> Traceback (most recent call last):
#> /tmp/ipykernel_463772/2209984829.py in <cell line: 1>()
#> ----> 1 leeds_driving_network.plot()
#> AttributeError: 'NoneType' object has no attribute 'plot'
# Here we request and plot ways that a friendly to pedestrians
leeds_walking_network = osm.get_network(network_type='walking')
leeds_walking_network.plot()
#> Traceback (most recent call last):
#> /tmp/ipykernel_463772/3815383564.py in <cell line: 1>()
#> ----> 1 leeds_walking_network.plot()
#> AttributeError: 'NoneType' object has no attribute 'plot'
# Here we request and plot ways that a friendly to cyclists
leeds_cycling_network = osm.get_network(network_type='cycling')
leeds_cycling_network.plot()
#> Traceback (most recent call last):
#> /tmp/ipykernel_463772/1723449363.py in <cell line: 1>()
#> ----> 1 leeds_cycling_network.plot()
#> AttributeError: 'NoneType' object has no attribute 'plot'
# View the number of rows of each network returned
print('all:', leeds_total_network.shape[0],
'\ndriving:', leeds_driving_network.shape[0],
'\nwalking:', leeds_walking_network.shape[0],
'\ncycling:', leeds_cycling_network.shape[0])
#> Traceback (most recent call last):
#> /tmp/ipykernel_463772/2184378707.py in <cell line: 2>()
#> 1 # View the number of rows of each network returned
#> 2 print('all:', leeds_total_network.shape[0],
#> ----> 3 '\ndriving:', leeds_driving_network.shape[0],
#> 4 '\nwalking:', leeds_walking_network.shape[0],
#> 5 '\ncycling:', leeds_cycling_network.shape[0])
#> AttributeError: 'NoneType' object has no attribute 'shape'
# Here we request and plot the dirivng and Public Service Vehicle network for Leeds
test_driving_and_psv = osm.get_network(network_type='driving_psv')
test_driving_and_psv.plot()
#> Traceback (most recent call last):
#> /tmp/ipykernel_463772/3864397027.py in <cell line: 1>()
#> ----> 1 test_driving_and_psv.plot()
#> AttributeError: 'NoneType' object has no attribute 'plot'
# Here we request and plot the driving + service network for Leeds
test_driving_and_Service = osm.get_network(network_type='driving+service')
test_driving_and_Service.plot()
#> Traceback (most recent call last):
#> /tmp/ipykernel_463772/2877354686.py in <cell line: 1>()
#> ----> 1 test_driving_and_Service.plot()
#> AttributeError: 'NoneType' object has no attribute 'plot' Environment setup (through terminal):
Packages on current conda environment:
|
@hulsiejames : Thanks for reporting and good reproducible examples. Will take a look this in the coming days. |
Hi, sorry to add to this, I'm having the same issue. I can only get one network for one session and need to restart the kernel to get another network. |
@lenkahas Hmm, quite weird behavior. Thanks for reporting, will also look at this. |
This has been hanging for veeery long, but I just tried to reproduce this error and things works as expected on my computer. I.e. I can retrieve multiple different networks using the same |
I think there may be a bug or at least issue within the OSM.get_network() function?
For reproducibility, this error has occurred on a system running Windows 10 (10.0.18363 Build 18363) with 16GB Ram and a i5-10310U Processor running python within a conda environment with the following packages installed.
I have been conducting my analysis in both the Spyder IDE (version: 5.1.5) and jupyter notebook (version: 6.4.8) both running Python 3.8.13.
I have been following along with the basic usage guide from the package documentation step by step and keep running into the same issue with get_network() described below.
As a resident of Leeds, I have been performing my analysis on this dataset as I understand what it should look like, rather than the Helsinki test datasets.
I get the the data and initialise the osm.pbf parser object as per the user guide
I am able to successfully obtain and plot the network of leeds using network_type='all' (next, I plan on demonstrating that specific networks i.e. "cycling", "driving" can be obtained by passing these to network_type= rather than "all")
So everything has worked as expected. However, now if I try to plot network_type='driving' exclusively, using the same osm parser object as before, a None type is returned.
returns the error:
I have also tried re-initialising the osm parser every time I request a new network, however this still yields the same results
Giving up on my analysis within a conda environment I decided I would try using google colab, which has worked exactly as expected and I was able to complete all steps demonstrated within the user guide.
Google colab running Python 3.7.13 (default, Mar 16 2022, 17:37:17) with the following packages installed:
I'm not too sure why I have been successful with Google colabs but not my local instances - any clarification would be greatly appreciated.
Many thanks
The text was updated successfully, but these errors were encountered: