2

I am very new to geoserver and SLD.

I am trying to put labels on my heatmap layer using SLD but the labels are not showing up in the preview. I found this example to implement it which looked straight forward yet it is not showing up.

Developing a Web Map Server Using GeoServer

I have been searching online and i haven't seen anything to help me troubleshoot this problem.

Here is my SLD:

<Rule>
        <RasterSymbolizer>
        <!-- specify geometry attribute to pass validation -->
          <Geometry>
            <ogc:PropertyName>wkb_geometry</ogc:PropertyName></Geometry>
          <Opacity>0.6</Opacity>
          <ColorMap type="ramp" >
            <ColorMapEntry color="#FFFFFF" quantity="0" 
              opacity="0"/>
            <ColorMapEntry color="#FFFFFF" quantity="0.02" label="nodata"
              opacity="0"/>
            <ColorMapEntry color="#4444FF" quantity=".1" label="nodata"/>
            <ColorMapEntry color="#FF0000" quantity=".5" label="values" />
            <ColorMapEntry color="#FFFF00" quantity="1.0" label="values" />
          </ColorMap>
        </RasterSymbolizer>
        <TextSymbolizer>
            <label>
                <ogc:PropertyName>aqi</ogc:PropertyName>
          </label>
       </TextSymbolizer>
       </Rule>

Here is a screenshot of the layer attributes:

enter image description here

2
  • First of all, I think you need a WPS extention, if not already installed? see discussion here. Also, this is a good guide
    – Cushen
    Commented Feb 3, 2017 at 1:22
  • Yes WPS is already installed and heatmap is generating. However I wanted to put labels on the heatmap with the TextSymbolizer using the aqi values but labels are not showing up.
    – Wiredo
    Commented Feb 3, 2017 at 15:38

1 Answer 1

2

You are trying to apply the textSymbolizer to the raster output rather than the underlying layer. I would move the labeling to a separate rule:

 <Rule>
    <RasterSymbolizer>
    <!-- specify geometry attribute to pass validation -->
      <Geometry>
        <ogc:PropertyName>wkb_geometry</ogc:PropertyName></Geometry>
      <Opacity>0.6</Opacity>
      <ColorMap type="ramp" >
        <ColorMapEntry color="#FFFFFF" quantity="0" 
          opacity="0"/>
        <ColorMapEntry color="#FFFFFF" quantity="0.02" label="nodata"
          opacity="0"/>
        <ColorMapEntry color="#4444FF" quantity=".1" label="nodata"/>
        <ColorMapEntry color="#FF0000" quantity=".5" label="values" />
        <ColorMapEntry color="#FFFF00" quantity="1.0" label="values" />
      </ColorMap>
    </RasterSymbolizer>
  </Rule>
  <Rule>
    <TextSymbolizer>
        <label>
            <ogc:PropertyName>aqi</ogc:PropertyName>
      </label>
   </TextSymbolizer>
   </Rule>
2
  • I tried it but it didn't work. It is still just showing the heatmap without labels.
    – Wiredo
    Commented Feb 2, 2017 at 16:20
  • You must match the attribute name exactly - so in your case AQI not aqi
    – Ian Turton
    Commented May 7, 2018 at 8:27

Your Answer

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

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