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

Handle nodata option for rasterized RGB image #5774

Merged
merged 5 commits into from
Jul 20, 2023
Merged

Handle nodata option for rasterized RGB image #5774

merged 5 commits into from
Jul 20, 2023

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Jun 21, 2023

Fixes holoviz/hvplot#1091

This will make it possible to do the following:

import hvplot.xarray  # noqa
import xarray as xr
import rioxarray as rxr

rgb_data = xr.load_dataarray("/home/shh/Downloads/sentinel2_seattle.nc")
rgb_data = xr.load_dataarray("https://github.com/ivandorte/datasets_samples/raw/main/sentinel2_seattle.nc")
rgb_plot = rgb_data.hvplot.rgb(x="x", y="y", bands="band", rasterize=True, tiles="OSM")
rgb_plot + rgb_plot.redim.nodata(R=0)

cog_url = "/home/shh/Downloads/5d7dad0becaf880008a9bc89.tif"
cog_url = "https://oin-hotosm.s3.amazonaws.com/5d7dad0becaf880008a9bc88/0/5d7dad0becaf880008a9bc89.tif"
da = rxr.open_rasterio(cog_url)
plot = da.hvplot.rgb(x="x", y="y", rasterize=True, tiles=True)
plot + plot.redim.nodata(R=0)

image

Todo:

  • Add test
  • Maybe automatically detect nodata in xarray DataArray/Dataset (this could be done in hvplot)

@codecov-commenter
Copy link

codecov-commenter commented Jun 21, 2023

Codecov Report

Merging #5774 (f03b135) into main (a12e33a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #5774   +/-   ##
=======================================
  Coverage   88.15%   88.16%           
=======================================
  Files         307      307           
  Lines       62908    62930   +22     
=======================================
+ Hits        55457    55480   +23     
+ Misses       7451     7450    -1     
Flag Coverage Δ
ui-tests 22.39% <8.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
holoviews/plotting/bokeh/raster.py 83.19% <100.00%> (+0.28%) ⬆️
holoviews/tests/element/test_raster.py 100.00% <100.00%> (ø)
holoviews/tests/plotting/bokeh/test_rasterplot.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

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

@hoxbro hoxbro merged commit ef1dd3b into main Jul 20, 2023
10 of 14 checks passed
@hoxbro hoxbro deleted the nodata_rgb branch July 20, 2023 11:46
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.

(hvplot.rgb) display nodata values as transparent not black
2 participants