I'm currently trying to apply shade relief effect to dem raster layer(geotiff format, one band with float samples, min and max are around 77 and 100) using geotools. I've tried diffrent parameters setups (factor and brigthness only flag), but effects are not even noticable. I'm wondering if it's my fault or this feature isn't implemented. I don't want to use gdal because I'd like to keep dem samples unchanged. I'm attaching code sample used to generate style applied to dem layer.

    StyleFactory sf = CommonFactoryFinder.getStyleFactory(null);
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
    ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.EXPONENTIAL);
    SelectedChannelType sct = sf.createSelectedChannelType(String.valueOf(1), ce);
    RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
    ChannelSelection sel = sf.channelSelection(sct);

    sym.setShadedRelief(new ShadedReliefBuilder().factor(22).brightnessOnly(true).build());

    Style style = SLD.wrapSymbolizers(sym);

1 Answer 1


Digging into this I have discovered that while there is no mention in the GeoTools docs in the downstream GeoServer docs there is a note that ShadedRelief is not implemented (yet).

However adding hill shading using GDAL does not alter your DEM but produces a new image to add over the top.

I usually use:

gdaldem hillshade -z 5 panorama.tif panorama_hs.tif -co tiled=yes -co compress=deflate

and an SLD file like:

<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
       <Title>Simple DEM style</Title>
      <Abstract>Hill Shading</Abstract>
              <sld:ColorMapEntry color="#000000" opacity="0.0" quantity="0.0"/>
              <sld:ColorMapEntry color="#999999" opacity="0.7" quantity="1.0"/>
              <sld:ColorMapEntry color="#FFFFFF" opacity="0.7" quantity="256.0"/>

Which when displayed over the top of my styled DEM looks like:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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