8
<Rule>
    <PointSymbolizer>
     <Graphic>
       <ExternalGraphic>
         <OnlineResource
           xlink:type="simple"
           xlink:href="glass.png" />
         <Format>image/png</Format>
       </ExternalGraphic>
       <Size>28</Size>
     </Graphic>
   </PointSymbolizer>
</Rule>

I want to use external graphics on my layers. I styled with geoserver admin panel. But external graphics are not working. I put my image into /var/www/geoserver/data/styles folder.

I tried some href options but not worked.

  • xlink:href="glass.png"
  • xlink:href="file:///glass.png"
  • xlink:href="/var/www/geoserver/glass.png"

I think another issue.

  • 1
    Your SLD looks very similar to "burg.sld" which is used in the demo layer "tiger:poi". There seems to be two ways for giving size but your way is also correct. Try to use your png symbol instead of "burg02.svg" for tiger:poi and check with layer preview that it is used. Change WMS Styles to "burg" from the extended options of the layer preview. Is /var/www/geoserver/data your data_dir? Your last xlink with full path seems to have a typo - /data/ missing from the path. – user30184 Nov 19 '14 at 8:19
4

Check if you have created the style definition inside a workspace.

If you are in this situation you have to place the png image into $GEOSERVER_DATA_DIR/wokspaces/{Name}/styles directory or any subdirectory.

i.e if you upload the image into the directory:

$GEOSERVER_DATA_DIR/workspaces/{yourWorkspace}/styles/images/earthquake.png

Your sld must look like this

        <Rule>
          <Title>Red flag</Title>
          <PointSymbolizer>
            <Graphic>
              <ExternalGraphic>
                <OnlineResource xlink:type="simple" xlink:href="images/earthquake.png" />
                <Format>image/png</Format>
              </ExternalGraphic>
              <Size>
                <ogc:Literal>20</ogc:Literal>
              </Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
3

This is modification of burg.sld that comes along with geoserver. I have provided earthquake.png in styles directory of GEOSERVER_DATA_DIRECTORY.

  <?xml version="1.0" encoding="ISO-8859-1"?>
    <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>redflag</Name>
        <UserStyle>
          <Name>burg</Name>
          <Title>A small red flag</Title>
          <Abstract>A sample of how to use an SVG based symbolizer</Abstract>

          <FeatureTypeStyle>
            <Rule>
              <Title>Red flag</Title>
              <PointSymbolizer>
                <Graphic>
                  <ExternalGraphic>
                    <OnlineResource xlink:type="simple" xlink:href="earthquake.png" />
                    <Format>image/png</Format>
                  </ExternalGraphic>
                  <Size>
                    <ogc:Literal>20</ogc:Literal>
                  </Size>
                </Graphic>
              </PointSymbolizer>
            </Rule>

          </FeatureTypeStyle>
        </UserStyle>
      </NamedLayer>
    </StyledLayerDescriptor>

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.