Skip to content

Commit

Permalink
Merge pull request #142 from oemof/revision/osmnx_2
Browse files Browse the repository at this point in the history
Update example osm_invest
  • Loading branch information
p-snft authored Jan 18, 2025
2 parents de8b30a + 8a2bf49 commit 7990133
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 7990133

Please sign in to comment.