Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mayer
CircularGreenSimCity
Commits
5e44ddf6
Commit
5e44ddf6
authored
Mar 27, 2024
by
Eric Duminil
Browse files
doc
parent
dc807658
Changes
1
Hide whitespace changes
Inline
Side-by-side
python_scripts/add_trees_to_open_street_map/add_trees.py
View file @
5e44ddf6
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
Script to automatically add potential trees in a given region, along roads and paths.
Script to automatically add potential trees in a given region, along roads and paths.
Road information is downloaded from OpenStreetMap.
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.
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
...
@@ -27,15 +28,12 @@ from import_existing_trees import get_existing_forest
# TODO: Document
# TODO: Document
# TODO: Write issue
# TODO: Write issue
# TODO: Write tests?
# TODO: Write tests?
# TODO: Export shapefile?
# From RegionChooser, or https://transfer.hft-stuttgart.de/gitlab/circulargreensimcity/circulargreensimcity/-/wikis/Fallstudien/Gromb%C3%BChl
# 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))"
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
# Replace with None if no existing tree should be imported
EXISTING_TREES
=
'existing_trees/Trees_ideal_2_20240227.shp'
EXISTING_TREES
=
'existing_trees/Trees_ideal_2_20240227.shp'
# EXISTING_TREES = 'existing_trees/baumkataster/Baum.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
EPSG_ID
=
25832
# Trees will be planted every TREE_DISTANCE along roads:
# Trees will be planted every TREE_DISTANCE along roads:
TREE_DISTANCE
=
10
# [m]
TREE_DISTANCE
=
10
# [m]
...
@@ -75,7 +73,7 @@ def get_osm_roads(bounds):
...
@@ -75,7 +73,7 @@ def get_osm_roads(bounds):
ways
=
pickle
.
load
(
cache
)
ways
=
pickle
.
load
(
cache
)
else
:
else
:
print
(
"Downloading data..."
)
print
(
"Downloading data..."
)
# TODO: Could add trees from OSM
or Bäumekataster
too.
# TODO: Could add trees from OSM too.
api
=
overpy
.
Overpass
()
api
=
overpy
.
Overpass
()
result
=
api
.
query
(
f
"""
result
=
api
.
query
(
f
"""
way(
{
bounds
.
S
}
,
{
bounds
.
W
}
,
{
bounds
.
N
}
,
{
bounds
.
E
}
) ["highway"];
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_
...
@@ -221,7 +219,7 @@ def export_shapefile(bounds: Bounds, forest: Forest, tree_distance: float, epsg_
'Bezeichnun'
:
t
.
description
,
'Baumart'
:
t
.
type
,
'Bezeichnun'
:
t
.
description
,
'Baumart'
:
t
.
type
,
'Baumhöhe'
:
t
.
height
,
'Kronenbrei'
:
t
.
diameter
,
'Baumhöhe'
:
t
.
height
,
'Kronenbrei'
:
t
.
diameter
,
'Stammumfan'
:
t
.
trunk_diameter
,
'Quelle'
:
t
.
source
'Stammumfan'
:
t
.
trunk_diameter
,
'Quelle'
:
t
.
source
}
}
for
t
in
forest
]
for
t
in
forest
]
df
=
pd
.
DataFrame
.
from_dict
(
data
)
df
=
pd
.
DataFrame
.
from_dict
(
data
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment