Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BigTIFF for image_to_cog #963

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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