I had the perfect hillshade raster ready to throw on top of my web map, I had previewed it in QGIS and the colour stretching and values looked fine.
I then loaded it into GeoServer and it looked great in the OpenLayers Layer Preview window as well.
However, once I added it as a WMS layer in a Leaflet map, I got really confused. Even though I had my NODATA=255 parameters seemingly working well there appeared a small strip around the outside of the image that was obnoxious.
I figured I could change it with an SLD but hadn’t done it before so it took a while to figure out. For a couple hours I tried various permutations of the default “raster” Style, but with no luck. The image, otherwise, looked great so the Style obviously wasn’t a real problem in and of itself.
The trick came when I realised that I need to set my color maps for the gray band explicitly. Up to this point no particular band had been isolated for color mapping. I found the right place to put the elements in the SLD and all worked out well.
My takeaway: there must be a better way to develop SLD for rasters. The options in the GeoServer docs are amazing and exciting, but trying to fit them into a specific context has always been a challenge for me. That’s why I had to write this down, but I’m sure I’ll have to remember it all again a year from now!
My SLD:
default_hillshade Raster Hillshade Grayscale hillshade SLD rule1 Hillshade with transparency Ignore values outside valid range, nodata values transparent 1
Thanks for you article! It is useful