-
Notifications
You must be signed in to change notification settings - Fork 1
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
[CIF-160] Group by a categorical raster like LULC #37
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Group by categorical raster works well both for the normal raster and large area raster
.gitignore
Outdated
@@ -163,3 +163,6 @@ cython_debug/ | |||
/keys | |||
keys/ | |||
wri-gee-358d958ce7c6.json | |||
|
|||
# notebooks, you need to `git add -f` to force them to be changed | |||
.ipynb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what happened here, but when I open this I see an an empty notebook.
|
||
# align to highest resolution raster, which should be the largest raster | ||
# since all are clipped to the extent | ||
raster_data = [data for data in mask_datum + [aggregate_data] if isinstance(data, xr.DataArray)] | ||
raster_data = [data for data in mask_datum + [aggregate_data] + [layer_data] if isinstance(data, xr.DataArray)] | ||
align_to = sorted(raster_data, key=lambda data: data.size, reverse=True).pop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this going to return the smallest since pop()
gets the last item and you are sorting them in reverse order?
What changes were proposed in this PR?
Besides grouping your results by a GeoDataFrame, allow grouping additionally by a categorical raster such as as a land use/land cover (LULC) layer. The results will be return as a dictionary for each zone of categorical value to the statistics. See the tests for examples.
How was this patch tested?
Unit tests were added to cover this case
Did this PR include necessary documentation updates?