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

allow the passing of options to RasterBand #36

Merged
merged 7 commits into from
Sep 27, 2023

Conversation

scottstanie
Copy link
Contributor

These get passed to rasterio.open(...)

See https://github.com/rasterio/rasterio/blob/5e001a08beb747fef0b60b5ccdbf2e5a08da7e05/docs/topics/image_options.rst#creation-options, or the driver specific options on the GDAL documentation (e.g. https://gdal.org/drivers/raster/gtiff.html)

Example usage:

In dolphin, I've got default creation options for the GTiff and ENVI drivers. These would get converted to rasterio-compatible ones with something like

gtiff_options = dict(opt.lower().split("=") for opt in io.DEFAULT_TIFF_OPTIONS)`
#  {'compress': 'deflate', 'zlevel': '4', 'tiled': 'yes', 'blockxsize': '128', 'blockysize': '128'}

then my RasterBand creation could be

unw_rb = RasterBand(
    unw_filename,
    height=height,
    width=width,
    dtype=np.float32,
    crs=crs,
    transform=transform,
    **gtiff_options,
)

@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

Merging #36 (e0de066) into main (d583e6d) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main      #36   +/-   ##
=======================================
  Coverage   97.86%   97.86%           
=======================================
  Files           9        9           
  Lines         797      797           
=======================================
  Hits          780      780           
  Misses         17       17           
Files Coverage Δ
src/tophu/_io.py 96.93% <100.00%> (ø)
src/tophu/_multiscale.py 96.36% <ø> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@gmgunter gmgunter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this seems like a very useful addition

src/tophu/_io.py Outdated Show resolved Hide resolved
src/tophu/_io.py Show resolved Hide resolved
@gmgunter gmgunter added this to the v0.2 milestone Sep 27, 2023
gmgunter and others added 5 commits September 26, 2023 22:17
Ensure that driver-specific keyword options were not supplied when
opening an existing raster band. These options can only be specified
when creating a new raster.
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
Minor updates to rasterio creation options PR
Copy link
Member

@gmgunter gmgunter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@gmgunter gmgunter merged commit 66df96f into isce-framework:main Sep 27, 2023
5 checks passed
@scottstanie scottstanie deleted the rasterio-creation-options branch September 27, 2023 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants