Perf: generate a footprint if none is passed in
For images with large nodata areas, passing in the footprint can speed up the GCP determination. Something like this can be used to determine the footprint from an input raster and could be part of the COREG class.
import geopandas as gpd # only for file reading, can also be replaced with ogr, fiona, shapely etc.
if footprint_poly_tgt is None:
run_cmd(["gdal_footprint", "-t_srs", "EPSG:4326", im_tgt, footprint_poly_tgt_file])
footprint_poly_tgt = str(gpd.read_file(target_mask_file).dissolve().geometry[0])
kwargs.update
"footprint_poly_tgt": footprint_poly_tgt,
}
Alternatives are:
- rasterio.features.shape
- https://raster-footprint.readthedocs.io/en/latest/