Created
January 4, 2022 16:31
-
-
Save pronitdas/376ce9f5bd05a1acaf423b60a03bf821 to your computer and use it in GitHub Desktop.
convert to cog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rio_cogeo.cogeo import cog_translate | |
from rio_cogeo.profiles import cog_profiles | |
def translate(src_path, dst_path, profile="deflate", profile_options={}, **options): | |
"""Convert image to COG.""" | |
output_profile = cog_profiles.get(profile) | |
output_profile.update(dict(BIGTIFF="IF_SAFER")) | |
output_profile.update(profile_options) | |
config = dict( | |
GDAL_NUM_THREADS="ALL_CPUS", | |
GDAL_TIFF_INTERNAL_MASK=True, | |
GDAL_TIFF_OVR_BLOCKSIZE="128", | |
) | |
cog_translate( | |
src_path, | |
dst_path, | |
output_profile, | |
config=config, | |
in_memory=False, | |
quiet=False, | |
**options, | |
) | |
return True | |
# print(cog_profiles) | |
translate('/home/pronit/workspace/processing/4e6708df-02bb-4856-a06b-cf599442da51_2021-09-09T16-54-43-236_transparent_mosaic_group1-transformed.tif', '/home/pronit/workspace/processing/4e6708df-02bb-4856-a06b-cf599442da51_2021-09-09T16-54-43-236_transparent_mosaic_group1-transformed-1.tif') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Libraries you need.
rio_cogeo
gdal >3.2