pysepal.mapping.tiling.prepare_for_tiles#
- pysepal.mapping.tiling.prepare_for_tiles(path, cache_dir=None, warp_to_3857=False, force=False, categorical=None)[source]#
Return a tiling-optimized copy of a raster, building it if needed.
The copy is cached under
cache_dirand reused on later calls, so repeat adds of the same raster cost nothing.- Parameters:
path (str) – Path to the source raster.
cache_dir (str | None) – Where to keep the optimized copy. Defaults to
default_cache_dir().warp_to_3857 (bool) – Reproject to Web Mercator, in the same pass that writes the COG.
force (bool) – Rebuild even when a cached copy is available.
categorical (bool | None) – Whether the values are class codes, which decides between NEAREST and AVERAGE overview resampling. Guessed from the dtype when not given.
- Returns:
{"path": optimized_path, "report": analyze_tif(optimized_path)}.pathis the source itself when no work was needed.- Return type:
dict