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

Minor updates to rasterio creation options PR #1

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
7 changes: 6 additions & 1 deletion src/tophu/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ def __init__(
transform : Affine instance, optional
Affine transformation mapping the pixel space to geographic space.
Defaults to None.
**options : dict, optional
Additional driver-specific creation options passed to `rasterio.open`.
"""
...

Expand All @@ -523,7 +525,9 @@ def __init__(
# If any of `width`, `height`, or `dtype` are provided, all three must be
# provided. If any were not provided, the dataset must already exist. Otherwise,
# create the dataset if it did not exist.
if (width is None) and (height is None) and (dtype is None):
# In addition, `options` may only be provided when creating a new dataset. It
# must be an empty dict when opening an existing dataset.
if (width is None) and (height is None) and (dtype is None) and (not options):
mode = "r"
count = None
elif (width is not None) and (height is not None) and (dtype is not None):
Expand Down Expand Up @@ -551,6 +555,7 @@ def __init__(
driver: str | None = None,
crs: str | dict | rasterio.crs.CRS | None = None,
transform: rasterio.transform.Affine | None = None,
**options: dict[str, Any],
)
""").strip()
raise TypeError(errmsg)
Expand Down