I have a raster published in my geoserver with default raster style as below
<NamedLayer>
<Name>default_raster</Name>
<UserStyle>
<!-- Styles can have names, titles and abstracts -->
<Title>Default Raster</Title>
<Abstract>A sample style that draws a raster, good for displaying imagery</Abstract>
<!-- FeatureTypeStyles describe how to render different features -->
<!-- A FeatureTypeStyle for rendering rasters -->
<FeatureTypeStyle>
<Rule>
<Name>rule1</Name>
<Title>Opaque Raster</Title>
<Abstract>A raster with 100% opacity</Abstract>
<RasterSymbolizer>
<Opacity>1.0</Opacity>
</RasterSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
Which has black color set for no data. I want to make the no data to transparent. How that can be done?
Best Answer
I'm not sure if this question is still relevant to anyone, but I found a solution using YSLD. Check out the documentation on the raster symbolizer and note the "intervals" color ramp. You can simply set the interval containing the no-data value to transparent. For example, if your no-data value is something north of 36000:
The format here is
[<color>,<transparency>,<cell value>,<symbol>]
. You can, of course, add more entries to symbolize other ranges of values. I hope this helps, even though it's a few years too late. :)