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

[CIF-160] Group by a categorical raster like LULC #37

Merged
merged 7 commits into from
Jun 6, 2024
Merged

Conversation

jterry64
Copy link
Member

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?

  • Yes, I am adding a new API feature.

Copy link
Member

@weiqi-tori weiqi-tori left a 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

@chrowe chrowe self-requested a review May 22, 2024 14:32
.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
Copy link
Contributor

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?

Copy link
Contributor

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()
Copy link
Contributor

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?

@jterry64 jterry64 merged commit cc41db2 into main Jun 6, 2024
1 check failed
@jterry64 jterry64 deleted the feature/group_by branch June 6, 2024 23:23
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.

3 participants