environmentaltools.drone.build_kmz_from_template
- environmentaltools.drone.build_kmz_from_template(kmz_folder: Path, csv_path: Path, limit: int | None, take: str, start_zero: bool, out_dir: Path | None, start_index: int | None = None, polygon_no: str | None = None, chunk_no: str | None = None)[source]
Build a KMZ file from a template folder and waypoints CSV data.
- Parameters:
kmz_folder (Path) – Template folder containing the wpmz subfolder with template.kml and WPML template.
csv_path (Path) – Path to the CSV file containing waypoint data.
limit (int, optional) – Maximum number of waypoints to process. If None, processes all waypoints.
take (str) – Strategy for selecting waypoints when limit is applied (“first” or “last”).
start_zero (bool) – If True, start waypoint indexing from 0 in the generated WPML.
out_dir (Path, optional) – Output directory for the generated KMZ file. If None, uses template folder’s parent.
start_index (int, optional) – Force a specific starting index for waypoint numbering. Overrides start_zero if provided.
polygon_no (str, optional) – Polygon identifier for output file naming structure.
chunk_no (str, optional) – Chunk/section identifier for output file naming structure.
- Returns:
Path to the generated KMZ file.
- Return type:
Path
- Raises:
SystemExit – If template folder, wpmz subfolder, template.kml, or WPML template is not found.
RuntimeError – If the generated archive is not found after creation.
Notes
The function creates a temporary directory, copies the template.kml file, generates a new waypoints.wpml from the CSV data using the WPML template, and packages everything into a KMZ (ZIP) archive.
The output naming convention is: - With polygon_no: “polygon_no/chunk_no.kmz” - Without polygon_no: “chunk_no.kmz”