import_existing_trees.py 615 Bytes
Newer Older
1
import geopandas as gpd
2
from tree import Tree, Forest
3

Eric Duminil's avatar
Eric Duminil committed
4
def get_existing_forest(shp_input):
5
    print(f"Importing {shp_input}")
6
    df = gpd.read_file(shp_input)
Eric Duminil's avatar
Eric Duminil committed
7
8
9
10
11
12
13
14
    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
                          ))
15
16
17
    return Forest(trees)

if __name__ == "__main__":
Eric Duminil's avatar
Eric Duminil committed
18
    print(repr(get_existing_forest('existing_trees/Trees_ideal_2_20240227.shp')))