Error When Trying To Extract The Information From Polygon Osmnx
When I try to extract information from the Manhattan polygon: import osmnx as ox city = ox.geocode_to_gdf(['Manhattan, New York, USA']) G = ox.graph_from_polygon(city, network_ty
Solution 1:
Your city
variable is a geopandas GeoDataFrame. The graph_from_polygon
function expects the polygon
argument to be of type shapely Polygon or MultiPolygon. See the docs. You're passing it an argument of the wrong type.
import networkx as nx
import osmnx as ox
city = ox.geocode_to_gdf(['Manhattan, New York, USA'])
polygon = city.iloc[0]['geometry']
G = ox.graph_from_polygon(polygon, network_type='drive', simplify=True)
G_nx = nx.relabel.convert_node_labels_to_integers(G)
nodes, edges = ox.graph_to_gdfs(G_nx, nodes=True, edges=True)
Post a Comment for "Error When Trying To Extract The Information From Polygon Osmnx"