Search code examples
pythonplotareaosmnx

I would like to get the area from latitude and longitude, and then put buildings etc etc


This is my main code `graph=ox.graph_from_point((60.199695, 24.948005), distance=500, network_type='drive_service')

area=ox.gdf_from_place(graph)

buildings = ox.footprints_from_place(graph)

nodes, edges = ox.graph_to_gdfs(graph)

fig, ax = ox.plot_graph(graph, show=False, close=False)

area.plot(ax=ax, facecolor='black')

edges.plot(ax=ax, linewidth=1, edgecolor='#BC8F8F')

buildings.plot(ax=ax, facecolor='khaki', alpha=0.7)

ax.scatter(floatlongitudes, floatlatitudes, c=concentration ,s=10)

plt.show()`

And I always get the same error in the area AssertionError: query must be a dict or a string I can't define a name for a place, is that why I chose create my area from latitude and longitude


Solution

  • I believe gdf_from_place requires specifically a place name (e.g. 'Sydney') as an argument and not a graph that has been obtained. Hence it throws up the error. I do not see another option in the documentation to obtain a gdf of the study area queried using

    graph=ox.graph_from_point((60.199695, 24.948005), distance=500, network_type='drive_service')
    

    There is an alternative for buildings though. Instead of buildings = ox.footprints_from_place(graph), you should use buildings = ox.footprints_from_point((60.199695, 24.948005), distance=500,) to get the result.