0

I am trying to style a DEM I created with QGIS. I have created the DEM as a GeoTiff and can successfully display the layer with Openlayers with the standard raster style in GeoServer. However, when applying a custom sld style I get no data displaying. My sld is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<sld:StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:sld="http://www.opengis.net/sld">
    <sld:UserLayer>
        <sld:LayerFeatureConstraints>
            <sld:FeatureTypeConstraint/>
        </sld:LayerFeatureConstraints>
        <sld:UserStyle>
            <sld:Name>DEM_3857</sld:Name>
            <sld:Title/>
            <sld:FeatureTypeStyle>
                <sld:Name/>
                <sld:Rule>
                    <sld:RasterSymbolizer>
                        <sld:Geometry>
                            <ogc:PropertyName>grid</ogc:PropertyName>
                        </sld:Geometry>
                        <sld:Opacity>1</sld:Opacity>
                        <sld:ColorMap>
                            <sld:ColorMapEntry color="#2b83ba" label="17.000000" opacity="1.0" quantity="17"/>
                            <sld:ColorMapEntry color="#abdda4" label="72.750000" opacity="1.0" quantity="72.75"/>
                            <sld:ColorMapEntry color="#ffffbf" label="128.500000" opacity="1.0" quantity="128.5"/>
                            <sld:ColorMapEntry color="#fdae61" label="184.250000" opacity="1.0" quantity="184.25"/>
                            <sld:ColorMapEntry color="#d7191c" label="240.000000" opacity="1.0" quantity="240"/>
                        </sld:ColorMap>
                    </sld:RasterSymbolizer>
                </sld:Rule>
            </sld:FeatureTypeStyle>
        </sld:UserStyle>
    </sld:UserLayer>
</sld:StyledLayerDescriptor>

Is there perhaps something I am missing here? The style shows in GeoServer as an option and functions when applied in QGIS so I assume there is another hidden issue.

1

Have a look at the dem.sld style file that comes with the GeoServer demo data. There are slight differences. Edit your SLD step by step so that it reminds the dem.sld file. Report back when you find what prevents GeoServer from using the QGIS style.

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
  <NamedLayer>
    <Name>gtopo</Name>
    <UserStyle>
      <Name>dem</Name>
      <Title>Simple DEM style</Title>
      <Abstract>Classic elevation color progression</Abstract>
      <FeatureTypeStyle>
        <Rule>
          <RasterSymbolizer>
            <Opacity>1.0</Opacity>
            <ColorMap>
              <ColorMapEntry color="#AAFFAA" quantity="0" label="values" />
              <ColorMapEntry color="#00FF00" quantity="1000"/>
              <ColorMapEntry color="#FFFF00" quantity="1200" label="values" />
              <ColorMapEntry color="#FF7F00" quantity="1400" label="values" />
              <ColorMapEntry color="#BF7F3F" quantity="1600" label="values" />
              <ColorMapEntry color="#000000" quantity="2000" label="values" />
            </ColorMap>
          </RasterSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>
0

The problem wasn't the style itself but the rather that the GeoTiff seem to have had no elevation values attached. I recreated the GeoTiff using ArcGIS and not Global Mapper as before and it worked straight away with my original style definition. I ensured that the elevation values were however included as integer values with the new GeoTiff file.

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.