diff --git a/python_scripts/add_trees_to_open_street_map/add_trees.py b/python_scripts/add_trees_to_open_street_map/add_trees.py index 4038f0e0c9d32dc6dc5e4477ae02c95d5b0253d9..a1096a0143d49fc23090bc7a155ff9c21b01e3d9 100644 --- a/python_scripts/add_trees_to_open_street_map/add_trees.py +++ b/python_scripts/add_trees_to_open_street_map/add_trees.py @@ -2,6 +2,7 @@ Script to automatically add potential trees in a given region, along roads and paths. Road information is downloaded from OpenStreetMap. +Existing trees can be imported from shapefiles if desired Trees are exported in a CSV table, a PNG diagram and an HTML interactive map. """ @@ -27,15 +28,12 @@ from import_existing_trees import get_existing_forest # TODO: Document # TODO: Write issue # TODO: Write tests? -# TODO: Export shapefile? # From RegionChooser, or https://transfer.hft-stuttgart.de/gitlab/circulargreensimcity/circulargreensimcity/-/wikis/Fallstudien/Gromb%C3%BChl WKT = "POLYGON((9.947021 49.803063, 9.947011 49.800917, 9.955025 49.800810, 9.955110 49.803019, 9.947021 49.803063))" # Replace with None if no existing tree should be imported EXISTING_TREES = 'existing_trees/Trees_ideal_2_20240227.shp' # EXISTING_TREES = 'existing_trees/baumkataster/Baum.shp' -# Fellbach -# WKT = "POLYGON((9.271353 48.811327, 9.271911 48.809010, 9.272147 48.807187, 9.275838 48.807173, 9.275602 48.806749, 9.276138 48.806325, 9.277683 48.806424, 9.277319 48.812514, 9.275581 48.811991, 9.271353 48.811327))" EPSG_ID = 25832 # Trees will be planted every TREE_DISTANCE along roads: TREE_DISTANCE = 10 # [m] @@ -75,7 +73,7 @@ def get_osm_roads(bounds): ways = pickle.load(cache) else: print("Downloading data...") - # TODO: Could add trees from OSM or Bäumekataster too. + # TODO: Could add trees from OSM too. api = overpy.Overpass() result = api.query(f""" way({bounds.S},{bounds.W},{bounds.N},{bounds.E}) ["highway"]; @@ -221,7 +219,7 @@ def export_shapefile(bounds: Bounds, forest: Forest, tree_distance: float, epsg_ 'Bezeichnun': t.description, 'Baumart': t.type, 'Baumhöhe': t.height, 'Kronenbrei': t.diameter, 'Stammumfan': t.trunk_diameter, 'Quelle': t.source - } + } for t in forest] df = pd.DataFrame.from_dict(data)