Useful window functions for large rasters. #2765
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds some new and useful functionality to Windows and windows submodule.
Windows.__contains__
:w1 in w2
determines ifw1
is contained entirely withinw2
.Windows.area
: Property that returns the area of a window.windows.neighbors
: Return the 8 neighboring windows of a given window in clockwise order (filtering 0-area windows).windows.subdivide
: Subdivide a given window into (x, y) sized subwindows.windows.merge
: Merge two windows into a larger window that exactly covers the two input windows.A minor utility function added to dtypes.py
dtypes.array_bytes
to compute the size of an array in bytes given a dtype and shape. I've used a similar function to compute optimal window sizes and avoid memory overallocation when processing large rasters.I welcome any feedback.