Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

osm.pdna_network_from_bbox error #181

Closed
SHITIANYU-hue opened this issue Oct 9, 2022 · 6 comments
Closed

osm.pdna_network_from_bbox error #181

SHITIANYU-hue opened this issue Oct 9, 2022 · 6 comments

Comments

@SHITIANYU-hue
Copy link

in the demo, when i run :

network = osm.pdna_network_from_bbox(37.698, -122.517, 37.819, -122.354) # San Francisco, CA

There will be error: ValueError: Assigning CRS to a GeoDataFrame without a geometry column is not supported. Use GeoDataFrame.set_geometry to set the active geometry column.

image

@sablanchard
Copy link
Collaborator

Hi @SHITIANYU-hue it looks like you do not have the optional package OSMnet installed in order to use that OSM network download function and thats why you have a geodataframe with no geometry column, see the error: modulenotfounderror in the traceback. try installing that package and trying it again. Ill close this issue for now.

@eric-gengzhou
Copy link

I encountered the same error but I do have the OSMnet package installed.

@larsschwarz
Copy link

Same here.

pandana 0.6.1
osmnet 0.1.6
geopandas 0.11.0

@knaaptime
Copy link

the error originates from osmnet, which pandana uses under the hood. The issue has been fixed upstream, so you can install the dev version of osmnet to get this working until a new release is made over there.

until then you could use osmnx to get the tables you need to input into pandana. Something like this should work

def pdna_network_from_gdf(gdf, network_type='walk'):
    
    graph = ox.graph_from_polygon(gdf.unary_union, network_type=network_type)
    n,e= ox.utils_graph.graph_to_gdfs(graph, geometry=False)
    e = e.reset_index()

    return pdna.Network(edge_from=e['u'], edge_to=e['v'], edge_weights=e[['length']], node_x=n['x'], node_y=n['y'])

@larsschwarz
Copy link

Thanks @knaaptime, I tried the pdna_network_from_gdf fix together the Pandana example. Removed geometry=False, because it triggers another error (TypeError: graph_to_gdfs() got an unexpected keyword argument 'geometry') which seems due to the Osmnx version I use.

However the lcn = network.low_connectivity_nodes(impedance=1000, count=10, imp_name='distance') from the example then triggers a

line 395, in _imp_name_to_num assert imp_name in self.impedance_names, "An impedance with that name" \AssertionError: An impedance with that namewas not found

error. Guess I'll try the dev version of osmnet instead now.

@knaaptime
Copy link

in the func i gave above the impedance column is "length", so maybe try imp_name='length'

(or you could rename the column from the edge table e=e.rename(columns={'length':'distance'}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants