(CoG = Cloud-optimized GeoTIFF)
Lambda's size limit doesn't allow packaging rasterio with OPeNDAP+GDAL. Thus, it is necessary to split into two workflows: OPeNDAP-to-GDAL and GDAL-to-CoG.
Raster IO can be used to generate CoG. The important part is picking the right block size. They should be a power of 2 between 64 and 4096. Default is 128.
$rio cogeo CER.tif CER_cog.tif --co BLOCKXSIZE=64 --co BLOCKYSIZE=64 --cog-profile raw
Here's the python code that is equivalent to the above command. This code can be used for Lambda.
import rasterio from rio_cogeo.cogeo import cog_translate from rio_cogeo.profiles import cog_profiles profile = cog_profiles.get("raw") profile.update({"blockxsize": 64, "blockysize": 64}) cog_translate("CER.tif", "cogeo.tif", profile)
The converted CoG can be validated with [5].
The final step is to save the CoG into S3 using [3] for better performance of CoG-based tools and services.