Drone Module

Drone utilities for environmental data collection and mission planning.

This module provides tools for drone-based environmental monitoring, including flight planning, waypoint generation, and mission management for DJI aircraft.

Features:
  • Scan pattern generation for photogrammetry surveys

  • KMZ mission file generation for DJI Pilot 2

  • Waypoint optimization and flight time calculation

  • Mission batching and management

  • Geographic data integration (GeoPackage, CSV)

Submodules:

build_scan_pattern: Generate scan patterns for aerial surveys drone_missions: Create and manage DJI mission files

Examples

Basic scan pattern generation:

>>> from environmentaltools.drone import build_scan_pattern
>>> config = {
...     'height': 100,
...     'fov_deg': 84,
...     'lateral_overlap': 0.8,
...     'longitudinal_overlap': 0.8
... }
>>> spacing = build_scan_pattern.calculate_scan_parameters(**config)

KMZ mission creation:

>>> from environmentaltools.drone import drone_missions
>>> drone_missions.create(
...     path="./missions",
...     polygon_no="001",
...     chunk_size=50,
...     template_path="template.kmz"
... )
Dependencies:

Core: pandas, geopandas, shapely Visualization: matplotlib, pillow Geospatial: pyproj, affine

The drone module provides comprehensive tools for unmanned aerial vehicle (UAV) mission planning, scan pattern generation, and flight data management for environmental monitoring applications.

Scan Pattern Generation

Flight Planning and Coverage Calculation

ground_coverage(height_m, fov_deg)

Calculates ground coverage width for a camera.

calculate_scan_parameters(height, fov_deg, ...)

Calculates scan parameters based on height and field of view.

calculate_flight_time(waypoints[, ...])

Calculates estimated flight time.

Polygon and Study Area Management

extract_polygons(geometry)

Extracts individual polygons from complex geometries.

load_study_area(filepath[, utm_zone])

Loads the study area from GeoPackage file.

filter_polygons(gdf_wgs84, gdf_utm[, ...])

Filters polygons according to specified indices.

Waypoint Generation

generate_scan_lines(polygon_utm, spacing)

Generates scan lines for a polygon.

create_waypoints_from_lines(lines, height, ...)

Creates waypoints from scan lines.

process_polygon(polygon_gps, polygon_utm, ...)

Processes an individual polygon generating its flight plan.

analysis(config)

Executes the complete waypoint generation analysis.

Data Export and Visualization

save_waypoints_csv(waypoints, output_path[, ...])

Saves waypoints in CSV format.

save_waypoints_gpkg(waypoints, output_path)

Saves waypoints in GeoPackage format.

plot_polygon_flight_plan(polygon_gps, ...)

Creates flight plan plots for an individual polygon.

plot_complete_flight_plan(gdf_wgs84, ...)

Creates complete flight plan plot.

Mission Management

DJI Mission File Generation

generate_wpml_from_csv(template_path, ...[, ...])

Generate a WPML file from a template and CSV waypoints data.

build_kmz_from_template(kmz_folder, ...[, ...])

Build a KMZ file from a template folder and waypoints CSV data.

create(template_kmz_folder, csv_path[, ...])

Generate multiple KMZ mission files by splitting waypoints CSV into chunks.

rename(path, polygon_no, missions_csv)

Rename mission files and folders based on names from a CSV file.

Mission Organization

list_dji_dirs(root)

List DJI directories excluding 'capability' and 'map_preview' folders.

create_preview(jpg_path, text[, size, ...])

Create a preview image with text overlay and optional waypoints map.

Integration with Other Modules

The drone module integrates seamlessly with other environmentaltools modules:

Spatial Module Integration

Use spatial analysis tools for pre-flight area assessment and post-flight data processing.

Common Module Integration

Leverage common utilities for coordinate transformations and data I/O operations.

Graphics Module Integration

Create publication-ready flight plan visualizations and mission summary plots.

Dependencies

Required
  • pandas: DataFrame operations and CSV handling

  • geopandas: Geospatial data processing

  • shapely: Geometric operations

  • matplotlib: Plotting and visualization

  • pillow: Image processing for mission previews

Optional
  • pyproj: Coordinate reference system transformations

  • affine: Geometric transformations