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

Add new .odc.explore() method for automatically plotting raster data on an interactive map #116

Merged
merged 3 commits into from
Jan 24, 2024

Conversation

robbibt
Copy link
Contributor

@robbibt robbibt commented Jan 4, 2024

This PR addresses #104 by adding a new .explore() method for automatically plotting raster data into an interactive map. This is designed to replicate the extremely useful .explore() method from Geopandas: https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.explore.html

Essentially explore combines to_rgba and add_to from this repo into a single easy to use method.

Supports single band xr.DataArray inputs:
image

Automatically converts xr.Dataset inputs to RGB:
image

And easily passing in custom mapping params like basemaps:
image

Copy link

codecov bot commented Jan 4, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (a9fbfc5) 97.91% compared to head (3bd9b9e) 97.88%.

Files Patch % Lines
odc/geo/_compress.py 85.71% 1 Missing ⚠️
odc/geo/_map.py 95.45% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #116      +/-   ##
===========================================
- Coverage    97.91%   97.88%   -0.04%     
===========================================
  Files           25       25              
  Lines         4315     4346      +31     
===========================================
+ Hits          4225     4254      +29     
- Misses          90       92       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Jan 4, 2024

@github-actions github-actions bot temporarily deployed to pull request January 4, 2024 04:06 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 4, 2024 04:33 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 4, 2024 04:40 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 4, 2024 05:39 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 4, 2024 06:42 Inactive
@robbibt robbibt marked this pull request as ready for review January 4, 2024 06:54
@robbibt robbibt requested a review from Kirill888 January 4, 2024 06:54
@github-actions github-actions bot temporarily deployed to pull request January 20, 2024 05:26 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 20, 2024 05:31 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 20, 2024 05:34 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 20, 2024 05:37 Inactive
@robbibt robbibt marked this pull request as draft January 20, 2024 22:30
@github-actions github-actions bot temporarily deployed to pull request January 21, 2024 03:41 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 21, 2024 03:44 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 21, 2024 03:47 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 21, 2024 03:52 Inactive
@robbibt robbibt force-pushed the explore branch 2 times, most recently from a26c406 to 678aa91 Compare January 21, 2024 03:56
@github-actions github-actions bot temporarily deployed to pull request January 21, 2024 03:58 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 21, 2024 07:15 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 21, 2024 23:24 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 21, 2024 23:29 Inactive
odc/geo/_map.py Outdated Show resolved Hide resolved
odc/geo/_map.py Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request January 23, 2024 06:56 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 23, 2024 07:02 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 23, 2024 07:04 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 23, 2024 23:23 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 23, 2024 23:26 Inactive
@robbibt robbibt marked this pull request as ready for review January 23, 2024 23:30
@robbibt
Copy link
Contributor Author

robbibt commented Jan 23, 2024

@Kirill888 Have made the following changes:

  • Simplified .explore() by using existing reprojection functionality in .add_to()
  • Added _verify_can_compress to catch unsuitable dims prior to Dask load in compress
  • Removed error catching from _compress_image now those errors are caught upstream
  • Added a new resample param to add_to() to control reprojection resampling method
  • Added a more user friendly ModuleNotFoundError if Folium isn't installed
  • Improved error messages for auto-band name guessing inside to_rgba()
  • Minor error message wording and documentation improvements

@Kirill888
Copy link
Member

@robbibt thanks, this is great. Let's put back those data shape checks into ._compress and it's good to merge after that.

@robbibt
Copy link
Contributor Author

robbibt commented Jan 24, 2024

@robbibt thanks, this is great. Let's put back those data shape checks into ._compress and it's good to merge after that.

Awesome, thanks for the great feedback. Have made that change, can rebase merge once you approve.

What's the plan for the next odc-geo version release? I'd like to get mask, crop and explore into the DEA Sandbox and it would be much easier with a proper release.

@github-actions github-actions bot temporarily deployed to pull request January 24, 2024 03:08 Inactive
@robbibt robbibt requested a review from Kirill888 January 24, 2024 03:10
Copy link
Member

@Kirill888 Kirill888 left a comment

Choose a reason for hiding this comment

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

thanks, good to merge

@robbibt robbibt merged commit 3b4374e into develop Jan 24, 2024
20 checks passed
@robbibt robbibt deleted the explore branch January 24, 2024 05:56
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.

Add a .odc.explore() method for automatically plotting raster data on an interactive map
2 participants