[GIS] Geoserver SLD creation using a local image

geoserversld

Using this documentation I have made the below SLD file, attempting to use an svg that I obtained from here I have moved the svg into /var/lib/tomcat7/webapps/geoserver/data/styles but the image will not render when previewing in the geoserver style editor (the return is a grey square). I've gone through this SE post and tried to reverse engineer it and have also used a direct path the result are the same. What am I missing?

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 
 xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
 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">
  <!-- a Named Layer is the basic building block of an SLD document -->
  <NamedLayer>
    <Name>default_point</Name>
    <UserStyle>
    <!-- Styles can have names, titles and abstracts -->
      <Title>Default Point</Title>
      <Abstract>A sample style that draws a point</Abstract>
      <!-- FeatureTypeStyles describe how to render different features -->
      <!-- A FeatureTypeStyle for rendering points -->
      <FeatureTypeStyle>
        <Rule>
          <Name>rule1</Name>
          <Title>platform</Title>
          <Abstract>Platform icon</Abstract>
            <PointSymbolizer>
                <Graphic>
                    <ExternalGraphic>
                        <OnlineResource xlink:type="simple" xlink:href="26 SUSPENDED-OILSHOW.svg"/>
                        <Format>image/svg+xml</Format>
                    </ExternalGraphic>
                    <Size>20</Size>
                </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

I was able to get it to work with a direct path xlink:href="file:////var/lib/tomcat7/webapps/geoserver/data/styles/26%20SUSPENDED-OILSHOW.svg" Why will it not work with a relative path?

Best Answer

I had the same problem.

In my case, the relative path was wrong.

Check in Server Status (first option in the left menu). There you can see the data directory, and your relative path for the image must start from there.

In your case, if the data directory is /var/lib/tomcat7/webapps/geoserver/data, the image relative path should be /styles/26%20SUSPENDED-OILSHOW.svg

Related Question