Skip to content

Commit

Permalink
Update example osm_invest
Browse files Browse the repository at this point in the history
osmnx renamed geometries_from_polygon to features_from_polygon and
removed the column "node".
  • Loading branch information
p-snft committed Dec 4, 2024
1 parent a66d25c commit 786bb0d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions examples/optimisation/import_osm_invest/import_osm_invest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,13 @@
graph = ox.graph_from_polygon(polygon, network_type='drive_service')
ox.plot_graph(graph)

gdf_poly_houses = ox.geometries_from_polygon(polygon, tags=buildings)
gdf_lines_streets = ox.geometries_from_polygon(polygon, tags=streets)
gdf_poly_houses = ox.features_from_polygon(polygon, tags=buildings)
gdf_lines_streets = ox.features_from_polygon(polygon, tags=streets)

# Make sure that only polygon geometries are used
gdf_poly_houses = gdf_poly_houses[gdf_poly_houses['geometry'].apply(
lambda x: isinstance(x, geometry.Polygon))]

# Remove nodes column (that make somehow trouble for exporting .geojson)
gdf_poly_houses.drop(columns=['nodes'], inplace=True)
gdf_lines_streets.drop(columns=['nodes'], inplace=True)

# We need one (or more) buildings that we call "generators".
# Choose one among the buildings at random and move it to a new GeoDataFrame
np.random.seed(42)
Expand Down

0 comments on commit 786bb0d

Please sign in to comment.