Skip to content

Commit

Permalink
Support BigTIFF for image_to_cog (#963)
Browse files Browse the repository at this point in the history
* Support BigTIFF for image_to_cog

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update BIGTIFF option

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
giswqs and pre-commit-ci[bot] authored Nov 5, 2024
1 parent 7b79f64 commit e7ab4be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion leafmap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3716,13 +3716,14 @@ def image_to_geotiff(image, dst_path, dtype=None, to_cog=True, **kwargs) -> None
image_to_cog(dst_path, dst_path)


def image_to_cog(source, dst_path=None, profile="deflate", **kwargs):
def image_to_cog(source, dst_path=None, profile="deflate", BIGTIFF=None, **kwargs):
"""Converts an image to a COG file.
Args:
source (str): A dataset path, URL or rasterio.io.DatasetReader object.
dst_path (str, optional): An output dataset path or or PathLike object. Defaults to None.
profile (str, optional): COG profile. More at https://cogeotiff.github.io/rio-cogeo/profile. Defaults to "deflate".
BIGTIFF (str, optional): Create a BigTIFF file. Can be "IF_SAFER" or "YES". Defaults to None.
Raises:
ImportError: If rio-cogeo is not installed.
Expand Down Expand Up @@ -3752,6 +3753,11 @@ def image_to_cog(source, dst_path=None, profile="deflate", **kwargs):
dst_path = check_file_path(dst_path)

dst_profile = cog_profiles.get(profile)
if "dst_kwargs" in kwargs:
dst_profile.update(kwargs.pop("dst_kwargs"))

if BIGTIFF is not None:
dst_profile.update({"BIGTIFF": BIGTIFF})
cog_translate(source, dst_path, dst_profile, **kwargs)


Expand Down

0 comments on commit e7ab4be

Please sign in to comment.