odc.geo.xr.to_cog
- odc.geo.xr.to_cog(geo_im, blocksize=None, ovr_blocksize=None, overviews=None, overview_resampling=None, overview_levels=None, use_windowed_writes=False, intermediate_compression=False, tags=None, **extra_rio_opts)[source]
Compress
xarray.DataArrayinto Cloud Optimized GeoTiff bytes in memory.This function doesn’t write to disk, it compresses in RAM, which is useful for saving data to S3 or other cloud object stores.
- Parameters:
geo_im (
DataArray) –xarray.DataArraywith crsblocksize (
Optional[int]) – Size of internal tiff tiles (512x512 pixels)ovr_blocksize (
Optional[int]) – Size of internal tiles in overview images (defaults to blocksize)overviews (
Optional[Iterable[DataArray]]) – Write pre-computed overviews if suppliedoverview_resampling (
Optional[str]) – Use this resampling when computing overviewsoverview_levels (
Optional[List[int]]) – List of shrink factors to compute overiews for: [2,4,8,16,32]nodata – Set
nodataflag to this value if supplied, by defaultnodatais read from the attributes of the input array (geo_im.attrs['nodata']).use_windowed_writes (
bool) – Write image block by block (might need this for large images)intermediate_compression (
Union[bool,str,Dict[str,Any]]) – Configure compression settings for first pass write , default is no compressiontags (
Optional[Dict[str,Any]]) – Dictionary of tags to write into the output file. These are written as GDAL Metadata items in the GeoTIFF file.extra_rio_opts – Any other option is passed to
rasterio.open
- Return type:
- Returns:
In-memory GeoTiff file as bytes