satellit_sam.core.inventory
satellit_sam.core.inventory
Auto-generated from
satellit_sam/src/satellit_sam/core/inventory.pybysatellit_sam/scripts/generate_api_docs.py.
Inventory loaders for CSV and shapefile-based tree records.
Functions
No public module-level functions.
Classes
Inventory
In-memory tree inventory loaded from CSV or shapefile sources.
Attributes
trees: list[Tree]
Methods
load_csv
def load_csv(
self,
csv_path: Path,
x_origin: float = 0.0,
y_origin: float = 0.0,
status_field="",
status_filter="",
x_field="",
y_field="",
dbh_field="",
dbh_unit: DbhUnit = "cm",
min_dbh_cm: float = 0.0,
max_dbh_cm: float = math.inf,
tree_id_field="",
stem_id_field="",
species_field="",
deduplicate_tree_id=True,
) -> None:
Load trees from CSV and map local offsets to WGS84 coordinates.
Arguments
csv_path: Semicolon-delimited inventory file. x_origin: WGS84 longitude origin in decimal degrees. y_origin: WGS84 latitude origin in decimal degrees. status_field: Column name containing tree status text. status_filter: Optional case-insensitive status filter. x_field: Column name for local X offset in meters. y_field: Column name for local Y offset in meters. dbh_field: Column name for DBH values. dbh_unit: Unit used by ``dbh_field`` values. min_dbh_cm: Minimum DBH threshold in centimeters. max_dbh_cm: Maximum DBH threshold in centimeters (<=0 disables upper bound). tree_id_field: Column name for tree identifier values. stem_id_field: Column name for stem identifier values. species_field: Column name for species values. deduplicate_tree_id: Whether to deduplicate by tree id after loading.
load_shp
def load_shp(
self,
shp_path: Path,
status_field="",
status_filter="",
dbh_field="",
dbh_unit: DbhUnit = "cm",
min_dbh_cm: float = 0.0,
max_dbh_cm: float = math.inf,
tree_id_field="",
stem_id_field="",
species_field="",
deduplicate_tree_id=True,
) -> None:
Load trees from a shapefile via GDAL/OGR.
Geometry coordinates are transformed to WGS84 (EPSG:4326) and stored as
tree longitude/latitude.
Arguments
shp_path: Path to source shapefile. status_field: Field name containing tree status text. status_filter: Optional case-insensitive status filter. dbh_field: Field name for DBH values. dbh_unit: Unit used by ``dbh_field`` values. min_dbh_cm: Minimum DBH threshold in centimeters. max_dbh_cm: Maximum DBH threshold in centimeters (<=0 disables upper bound). tree_id_field: Field name for tree identifier values. stem_id_field: Field name for stem identifier values. species_field: Field name for species values. deduplicate_tree_id: Whether to deduplicate by tree id after loading.
Exceptions
FileNotFoundError: If the shapefile cannot be opened. ValueError: If the first layer cannot be read.
deduplicate_trees
def deduplicate_trees(self) -> None:
Keep one row per tree id, preferring the highest DBH record.
Rows without a tree id are retained unchanged.