environmentaltools.drone.generate_wpml_from_csv
- environmentaltools.drone.generate_wpml_from_csv(template_path: Path, csv_path: Path, out_path: Path, limit: int = None, take: str = 'first', start_zero: bool = False, start_index: int | None = None)[source]
Generate a WPML file from a template and CSV waypoints data.
- Parameters:
template_path (Path) – Path to the WPML template file (waylines.wpml).
csv_path (Path) – Path to the CSV file containing waypoint data with longitude and latitude columns.
out_path (Path) – Output path for the generated WPML file.
limit (int, optional) – Maximum number of waypoints to process. If None, processes all waypoints.
take (str, optional) – Strategy for selecting waypoints when limit is applied. Either “first” or “last”. Default is “first”.
start_zero (bool, optional) – If True, start waypoint indexing from 0. If False, start from 1. Default is False.
start_index (int, optional) – Force a specific starting index for waypoint numbering. Overrides start_zero if provided.
- Returns:
Writes the generated WPML file to the specified output path.
- Return type:
None
- Raises:
RuntimeError – If no <Folder> element is found in the template. If no <Placemark> elements are found in the template folder.
FileNotFoundError – If the template file or CSV file doesn’t exist.
Notes
The function expects CSV data with columns that can be detected as longitude/latitude: - Longitude: ‘lon’, ‘lng’, ‘longitude’, ‘x’ - Latitude: ‘lat’, ‘latitude’, ‘y’
The template WPML file should contain at least one <Placemark> element that will be used as a template for generating new placemarks for each waypoint.
Action group indices within placemarks are automatically incremented to ensure unique identification across all generated waypoints.