OpenGeo

OpenGeo Stack Workshop

Previous topic

Creating a New SLD

Next topic

Scale Dependent Rendering with SLD

External Graphics with SLD

The style added in the previous section is very basic. With point based data it is often desired to style the point with an existing glyph or icon. This section covers the task of modifying a point style to render a graphic contained in an existing image file.

  1. From the Welcome Page return to the style editor by navigating Config ‣ Data ‣ Style. Select bus_stop_style from the drop down and click Edit.

    ../_images/sld_create5.jpg

    Editing the bus_stops_style

  2. Between the <PointSymbolizer></PointSymbolizer> tags add the following XML:

    <Graphic>
      <ExternalGraphic>
        <OnlineResource xlink:type="simple" xlink:href="bus.png" />
        <Format>image/png</Format>
      </ExternalGraphic>
    </Graphic>
    
    ../_images/sld_create6.jpg

    Adding an external graphic

    Note

    The <ExternalGraphic> element is used to render a point using a pre-existing icon in a jpeg, gif, png, svg, etc... format. In this example an icon named bus.png is being used.

  3. Submit, Apply, and Save changes.

  4. Refresh the Map Preview.

    ../_images/sld_create7.jpg

    The bus_stops_style rendered with an external graphic.

At this point the SLD created from scratch is more interesting than a red dot but is still lacking. The next few sections focus on adding improving the style.