Commit 6c1c17c5 authored by Eric Duminil's avatar Eric Duminil
Browse files

Adding heights to CSV

parent 5e44ddf6
...@@ -203,15 +203,15 @@ def export_csv(bounds, forest, wkt_polygon, tree_distance, min_distance, epsg_id ...@@ -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"# Tree distance along roads; {tree_distance}; [m]\n")
csv.write(f"# Minimum allowed distance between trees; {min_distance}; [m]\n") csv.write(f"# Minimum allowed distance between trees; {min_distance}; [m]\n")
csv.write(f"# EPSG; {epsg_id}\n") csv.write(f"# EPSG; {epsg_id}\n")
csv.write("# X; Y; Type; Description; Radius; Source\n") csv.write("# X; Y; Type; Description; Radius; Height; Source\n")
csv.write("# [m]; [m]; [-]; [-]; [m]; [-]\n") csv.write("# [m]; [m]; [-]; [-]; [m]; [m]; [-]\n")
for tree in forest: 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!") 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") print("Exporting shapefile")
data = [{ data = [{
...@@ -233,7 +233,7 @@ def export_shapefile(bounds: Bounds, forest: Forest, tree_distance: float, epsg_ ...@@ -233,7 +233,7 @@ def export_shapefile(bounds: Bounds, forest: Forest, tree_distance: float, epsg_
basename = get_basename(bounds) basename = get_basename(bounds)
shp_dir = OUTPUT_DIR / basename shp_dir = OUTPUT_DIR / basename
shp_dir.mkdir(exist_ok=True) 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!") print(" DONE!")
...@@ -258,7 +258,7 @@ def main(wkt_polygon, epsg_id, tree_distance, min_distance, import_tree_shp) -> ...@@ -258,7 +258,7 @@ def main(wkt_polygon, epsg_id, tree_distance, min_distance, import_tree_shp) ->
plot_trees(bounds, forest, tree_distance) plot_trees(bounds, forest, tree_distance)
export_map(bounds, forest, epsg_id) export_map(bounds, forest, epsg_id)
export_csv(bounds, forest, wkt_polygon, tree_distance, min_distance, 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__": if __name__ == "__main__":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment