Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CircularGreenSimCity
CircularGreenSimCity
Compare Revisions
a1cb6c534469621f4d6e3fdf082cc1b4fc69eadd...07eab64d7dac6a257e105e8bfe8814d74d367962
Commits (2)
Add height information
· 50f76a62
Eric Duminil
authored
Mar 26, 2024
50f76a62
Trunk diameter too
· 07eab64d
Eric Duminil
authored
Mar 26, 2024
07eab64d
Hide whitespace changes
Inline
Side-by-side
python_scripts/add_trees_to_open_street_map/add_trees.py
View file @
07eab64d
...
...
@@ -145,6 +145,7 @@ def place_trees(forest, ways, region, to_local, tree_distance, min_distance_2) -
type
=
'Fake Tree'
,
description
=
'Tilia tomentosa'
,
diameter
=
6
,
height
=
10
,
source
=
'add_trees.py'
)
...
...
@@ -219,7 +220,7 @@ def export_shapefile(bounds: Bounds, forest: Forest, tree_distance: float, epsg_
'x'
:
t
.
x
,
'y'
:
t
.
y
,
'Bezeichnun'
:
t
.
description
,
'Baumart'
:
t
.
type
,
'Baumhöhe'
:
t
.
height
,
'Kronenbrei'
:
t
.
diameter
,
'Quelle'
:
t
.
source
,
'Stammumfan'
:
t
.
trunk_diameter
,
'Quelle'
:
t
.
source
}
for
t
in
forest
]
...
...
@@ -234,7 +235,7 @@ def export_shapefile(bounds: Bounds, forest: Forest, tree_distance: float, epsg_
basename
=
get_basename
(
bounds
)
shp_dir
=
OUTPUT_DIR
/
basename
shp_dir
.
mkdir
(
exist_ok
=
True
)
gdf
.
to_file
(
shp_dir
/
f
"trees.shp"
)
gdf
.
to_file
(
shp_dir
/
f
"trees.shp"
,
encoding
=
'UTF-8'
)
print
(
" DONE!"
)
...
...
python_scripts/add_trees_to_open_street_map/import_existing_trees.py
View file @
07eab64d
...
...
@@ -13,9 +13,11 @@ def get_existing_forest(shp_input):
diameter
=
tree_row
.
Kronenbrei
,
type
=
tree_row
.
Baumart
,
trunk_diameter
=
tree_row
.
Stammumfan
,
height
=
tree_row
.
Baumhöhe
,
source
=
Path
(
shp_input
).
name
))
return
Forest
(
trees
)
if
__name__
==
"__main__"
:
print
(
repr
(
get_existing_forest
(
'existing_trees/Trees_ideal_2_20240227.shp'
)))
# print(repr(get_existing_forest('output/49_80081__49_803063__9_947011__9_95511_10m/trees.shp')))
python_scripts/add_trees_to_open_street_map/tree.py
View file @
07eab64d
...
...
@@ -8,8 +8,8 @@ class Tree:
x
:
float
y
:
float
diameter
:
float
height
:
float
z
:
float
=
0
height
:
float
=
None
trunk_diameter
:
float
=
None
type
:
str
=
None
description
:
str
=
'?'
...
...
@@ -27,7 +27,7 @@ class Tree:
return
self
.
diameter
/
2
def
__str__
(
self
):
return
f
"
{
self
.
type
}
(
{
self
.
description
}
),
{
self
.
radius
}
m (X=
{
self
.
x
:.
1
f
}
, Y=
{
self
.
y
:.
1
f
}
)"
return
f
"
{
self
.
type
}
(
{
self
.
description
}
),
{
self
.
radius
}
m
radius,
{
self
.
height
}
m height,
(X=
{
self
.
x
:.
1
f
}
, Y=
{
self
.
y
:.
1
f
}
)"
class
Forest
(
UserList
):
...
...