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
6c1c17c5
Commit
6c1c17c5
authored
Apr 02, 2024
by
Eric Duminil
Browse files
Adding heights to CSV
parent
5e44ddf6
Changes
1
Hide whitespace changes
Inline
Side-by-side
python_scripts/add_trees_to_open_street_map/add_trees.py
View file @
6c1c17c5
...
...
@@ -203,15 +203,15 @@ 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; Type; Description; Radius; Source
\n
"
)
csv
.
write
(
"# [m]; [m]; [-]; [-]; [m]; [-]
\n
"
)
csv
.
write
(
"# X; Y; Type; Description; Radius;
Height;
Source
\n
"
)
csv
.
write
(
"# [m]; [m]; [-]; [-]; [m];
[m];
[-]
\n
"
)
for
tree
in
forest
:
csv
.
write
(
f
"
{
tree
.
x
}
;
{
tree
.
y
}
;
{
tree
.
type
}
;
{
tree
.
description
}
;
{
tree
.
radius
}
;
{
tree
.
source
}
\n
"
)
csv
.
write
(
f
"
{
tree
.
x
}
;
{
tree
.
y
}
;
{
tree
.
type
}
;
{
tree
.
description
}
;
{
tree
.
radius
}
;
{
tree
.
height
}
;
{
tree
.
source
}
\n
"
)
print
(
" DONE!"
)
def
export_shapefile
(
bounds
:
Bounds
,
forest
:
Forest
,
tree_distance
:
float
,
epsg_id
:
str
)
->
None
:
def
export_shapefile
(
bounds
:
Bounds
,
forest
:
Forest
,
epsg_id
:
str
)
->
None
:
print
(
"Exporting shapefile"
)
data
=
[{
...
...
@@ -233,7 +233,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"
,
encoding
=
'UTF-8'
)
gdf
.
to_file
(
shp_dir
/
"trees.shp"
,
encoding
=
'UTF-8'
)
print
(
" DONE!"
)
...
...
@@ -258,7 +258,7 @@ def main(wkt_polygon, epsg_id, tree_distance, min_distance, import_tree_shp) ->
plot_trees
(
bounds
,
forest
,
tree_distance
)
export_map
(
bounds
,
forest
,
epsg_id
)
export_csv
(
bounds
,
forest
,
wkt_polygon
,
tree_distance
,
min_distance
,
epsg_id
)
export_shapefile
(
bounds
,
forest
,
tree_distance
,
epsg_id
)
export_shapefile
(
bounds
,
forest
,
epsg_id
)
if
__name__
==
"__main__"
:
...
...
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