Skip to content

Documentation for retrieve_shape_for_site

Path: boundary_segmentation/retrieve_shape_for_site.py

Module Description

Geospatial ML Pipeline - Retrieves imagery, runs ML model and returns GeoJSON boundaries.

Functions

create_point_buffer_meters

Create a buffer polygon around a point with the buffer distance in meters.

Args: longitude: Longitude of the point (in decimal degrees) latitude: Latitude of the point (in decimal degrees) buffer_distance_meters: Buffer distance in meters

Returns: GeoJSON string representing the buffer polygon

retrieve_imagery

Retrieve imagery for the specified location.

Args: latitude: Latitude coordinate longitude: Longitude coordinate provider: Image provider name ('esri' or 'naip') padding: Buffer distance in meters output_folder: Output directory path zoom: Optional zoom level override

Returns: Tuple of (success, tif_path, jpg_path or error message)

process_imagery

Run ML model on image and generate GeoJSON output. Only keeps polygons containing the initial point, then dissolves and simplifies them.

Args: tif_path: Path to the GeoTIFF image with geospatial information jpg_path: Path to the JPG image for model input model_weights: Path to model weights file cut_off: Confidence threshold for predictions output_folder: Output directory path base_name: Base name for output files latitude: Latitude of the initial point longitude: Longitude of the initial point buffer_distance: Buffer distance in meters to add to the final polygon simplify_tolerance: Tolerance for polygon simplification device: Device to run model on ('cpu' or 'cuda')

Returns: Tuple of (success, result_path or error message)

main

Main entry point for the application.