odc.geo.cog.to_cog
- odc.geo.cog.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.DataArray
into 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.DataArray
with 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
nodata
flag to this value if supplied, by defaultnodata
is 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