I have a raster published in my geoserver with default raster style as below

<!-- 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 -->
      <Title>Opaque Raster</Title>
      <Abstract>A raster with 100% opacity</Abstract>

And my imagery looks like enter image description here

Which has black color set for no data. I want to make the no data to transparent. How that can be done?


I don't think it can be done with SLD. Publish your imagery as a image mosaic and change the "input transparent color" to black instead.

| improve this 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:

title: Discrete Ramp'
- name: raster
  - name: raster
  - symbolizers:
    - raster:
        opacity: 1.0
          type: intervals
          - ['#000000',0, 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. :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.