You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reading the raster, the photometric option might be available in the profile and you could add that to the attributes.
Then, you could add a method to convert the rasterio.enums.ColorInterp to a photometric option and write that attribute to the xarray object's attributes and update to_raster to look for that.
Without modifying rioxarray, you can use the photometric option when writing to raster.
rds.rio.to_raster(...,photometric="RGB")
Otherwise, you will have to use rasterio to update the colorinterp as rioxarray doesn't support the update mode.
Hi there 👋, I'm interested in adding the color interpretation feature too. We're thinking of integrating rioxarray in PyGMT (see thread at GenericMappingTools/pygmt#1555) and would be keen to help out 😄
Hi @weiji14, it would definitely be great if you would like to add the functionality.
The main changes that need to happen are:
Load in the attributes when reading a file from rasterio ref. These will need to be converted into string/numeric types as necessary. This is so you can call .to_netcdf() without serialization issues.
Write the attributes to the file ref. These will need to be converted to rasterio types as necessary.
If you are feeling extra motivated, you could add methods to the rio accessor to read/write color interpretation to the xarray object.
Activity
snowman2 commentedon Nov 24, 2020
When reading the raster, the
photometricoption might be available in the profile and you could add that to the attributes.Then, you could add a method to convert the
rasterio.enums.ColorInterpto a photometric option and write that attribute to the xarray object's attributes and updateto_rasterto look for that.Without modifying rioxarray, you can use the
photometricoption when writing to raster.Otherwise, you will have to use
rasterioto update thecolorinterpasrioxarraydoesn't support the update mode.snowman2 commentedon Nov 24, 2020
Another option would be to add a
colorinterpkwarg toto_raster:weiji14 commentedon Oct 1, 2021
Hi there 👋, I'm interested in adding the color interpretation feature too. We're thinking of integrating
rioxarrayin PyGMT (see thread at GenericMappingTools/pygmt#1555) and would be keen to help out 😄If it's just a matter of applying pydata/xarray#3136 to the
_get_rasterio_attrsfunction, I could probably open a quick PR for thisBut to open a can of worms, is it ok to just store the color table in the
xarray.DataArray'sattr? Or should the RGB colors be read as separate bands? Just thinking how it will work with plotting the image later using.plot.imshow()(e.g. with the https://corteva.github.io/rioxarray/latest/examples/COG.html example).snowman2 commentedon Oct 1, 2021
Hi @weiji14, it would definitely be great if you would like to add the functionality.
The main changes that need to happen are:
.to_netcdf()without serialization issues.If you are feeling extra motivated, you could add methods to the
rioaccessor to read/write color interpretation to the xarray object.snowman2 commentedon Oct 1, 2021
Side note, to plot RGB bands, here is an example ref