Skip to content

Documentation for convert_to_coco_dataset

Path: utils/convert_to_coco_dataset.py

Module Description

GeoJSON to COCO Annotation Converter

Converts GeoJSON point features to COCO format annotations for object detection.

Functions

setup_logging

Configure logging based on verbosity level.

create_bbox

Create a bounding box around a point with specified buffer distance. Based on the geo_coords_to_pixel_coords approach from the reference code.

Args: point_coords: Longitude and latitude coordinates (lon, lat) buffer_meters: Buffer distance in meters transform: Rasterio affine transform image_width: Width of the image in pixels image_height: Height of the image in pixels

Returns: List containing [x, y, width, height] in COCO format or None if invalid

find_matching_geotiff

Find a matching GeoTIFF file for a site name.

process_geojson_files

Process all GeoJSON files in a site folder.

main

Main function to run the conversion process.