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
f1ef4381
Commit
f1ef4381
authored
Mar 26, 2024
by
Eric Duminil
Browse files
More info from tabs
parent
361b1885
Changes
3
Hide whitespace changes
Inline
Side-by-side
python_scripts/add_trees_to_open_street_map/add_trees.py
View file @
f1ef4381
...
...
@@ -137,7 +137,8 @@ def place_trees(forest, ways, region, to_local, tree_distance, min_distance_2) -
if
local_region
.
contains
(
geometry
.
Point
(
x
,
y
)):
forest
.
add_tree_if_possible
(
min_distance_2
,
x
,
y
,
color
=
'#DFFF00'
,
description
=
'Fake Tree'
,
type
=
'Fake Tree'
,
description
=
'Tilia tomentosa'
radius
=
3
)
...
...
@@ -145,6 +146,7 @@ def place_trees(forest, ways, region, to_local, tree_distance, min_distance_2) -
def
plot_trees
(
bounds
,
forest
,
tree_distance
)
->
None
:
print
(
"Exporting diagram..."
)
tree_xs
,
tree_ys
,
colors
=
forest
.
xs_ys_cs
plt
.
scatter
(
tree_xs
,
tree_ys
,
s
=
2
,
c
=
colors
)
...
...
@@ -195,10 +197,10 @@ def export_csv(bounds, forest, wkt_polygon, tree_distance, min_distance, epsg_id
csv
.
write
(
f
"# Tree distance along roads;
{
tree_distance
}
; [m]
\n
"
)
csv
.
write
(
f
"# Minimum allowed distance between trees;
{
min_distance
}
; [m]
\n
"
)
csv
.
write
(
f
"# EPSG;
{
epsg_id
}
\n
"
)
csv
.
write
(
"# X; Y
\n
"
)
csv
.
write
(
"# [m]; [m]
\n
"
)
csv
.
write
(
"# X; Y
; Type; Description; Radius
\n
"
)
csv
.
write
(
"# [m];
[m]; [?]; [?];
[m]
\n
"
)
for
tree
in
forest
:
csv
.
write
(
f
"
{
tree
.
x
}
;
{
tree
.
y
}
\n
"
)
csv
.
write
(
f
"
{
tree
.
x
}
;
{
tree
.
y
}
;
{
tree
.
type
}
;
{
tree
.
description
}
;
{
tree
.
radius
}
\n
"
)
print
(
" DONE!"
)
...
...
python_scripts/add_trees_to_open_street_map/import_existing_trees.py
View file @
f1ef4381
...
...
@@ -4,7 +4,14 @@ from tree import Tree, Forest
def
get_existing_forest
(
shp_input
):
print
(
f
"Importing
{
shp_input
}
"
)
df
=
gpd
.
read_file
(
shp_input
)
trees
=
[
Tree
(
p
.
x
,
p
.
y
)
for
p
in
df
.
geometry
]
trees
=
[]
for
tree_row
in
df
.
itertuples
():
point
=
tree_row
.
geometry
trees
.
append
(
Tree
(
point
.
x
,
point
.
y
,
description
=
tree_row
.
Bezeichnun
,
radius
=
tree_row
.
Kroneradi
,
type
=
tree_row
.
Baumart
))
return
Forest
(
trees
)
if
__name__
==
"__main__"
:
...
...
python_scripts/add_trees_to_open_street_map/tree.py
View file @
f1ef4381
...
...
@@ -10,8 +10,8 @@ class Tree:
z
:
float
=
0
height
:
float
=
None
radius
:
float
=
None
description
:
str
=
None
type
:
str
=
None
description
:
str
=
'?'
color
:
str
=
'green'
def
__len__
(
self
):
...
...
@@ -21,7 +21,7 @@ class Tree:
return
[
self
.
x
,
self
.
y
][
i
]
def
__str__
(
self
):
return
f
"
{
self
.
description
}
,
{
self
.
radius
or
'?'
}
m (X=
{
self
.
x
:
.
1
f
}
, Y=
{
self
.
y
:
.
1
f
}
)"
return
f
"
{
self
.
type
}
(
{
self
.
description
}
)
,
{
self
.
radius
or
'?'
}
m (X=
{
self
.
x
:
.
1
f
}
, Y=
{
self
.
y
:
.
1
f
}
)"
class
Forest
(
UserList
):
...
...
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