2

I have created my SLD's in QGIS and want to use them in Geoserver. I have imported and validated them without any problems

but when I try to view the data using Layer Preview --> OpenLayers-->Go it tries to download the data rather than let me view it. With the default symbology it works fine.

Is there something fundamental that I have to change in the SLD from Geoserver for it to work?

One of the simple and 2 complex SLD's are below (roads at different zoom levels)

Roads - Simple

    <?xml version="1.0" encoding="UTF-8"?>
    <StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:se="http://www.opengis.net/se">
  <NamedLayer>
    <se:Name>Roads_GHD_20121121</se:Name>
    <UserStyle>
      <se:Name>Roads_GHD_20121121</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>GHD Roads</se:Name>
          <se:MaxScaleDenominator>250000</se:MaxScaleDenominator>
          <se:LineSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#ff0000</se:SvgParameter>
              <se:SvgParameter name="stroke-width">0.4</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
              <se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
              <se:SvgParameter name="stroke-dasharray">5 2</se:SvgParameter>
            </se:Stroke>
          </se:LineSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Roads - Complex

<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">
    <NamedLayer>
        <Name>Road with border</Name>
        <UserStyle>
            <Title>Road with border</Title>

            <!-- Local Roads -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>0</MinScaleDenominator>
                    <MaxScaleDenominator>1787</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">12</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>0</MinScaleDenominator>
                    <MaxScaleDenominator>1787</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFFFF</CssParameter>
                            <CssParameter name="stroke-width">11</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFFFF</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- Local Roads 1787 - 3573-->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>1787</MinScaleDenominator>
                    <MaxScaleDenominator>3573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">7</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>1787</MinScaleDenominator>
                    <MaxScaleDenominator>3573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFFFF</CssParameter>
                            <CssParameter name="stroke-width">6</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFFFF</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>                        
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- Local Roads 3573 - 28573-->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>3573</MinScaleDenominator>
                    <MaxScaleDenominator>28573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">4</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>

Points Complex with SVG files.

                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>3573</MinScaleDenominator>
                    <MaxScaleDenominator>28573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFFFF</CssParameter>
                            <CssParameter name="stroke-width">3</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFFFF</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- Local Roads 28573 - 114287 -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>Y</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>28573</MinScaleDenominator>
                    <MaxScaleDenominator>114287</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#D7C29E</CssParameter>
                            <CssParameter name="stroke-width">1</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- State Roads - 0 - 1787 -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>0</MinScaleDenominator>
                    <MaxScaleDenominator>1787</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">13</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>0</MinScaleDenominator>
                    <MaxScaleDenominator>1787</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFF00</CssParameter>
                            <CssParameter name="stroke-width">12</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFF00</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- State Roads - 1787 - 3572 -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>1787</MinScaleDenominator>
                    <MaxScaleDenominator>3573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">7</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>1787</MinScaleDenominator>
                    <MaxScaleDenominator>3573</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFF00</CssParameter>
                            <CssParameter name="stroke-width">6</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFF00</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>                        
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>

            <!-- State Roads - 3572 - infinity -->
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>3573</MinScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#CDAA66</CssParameter>
                            <CssParameter name="stroke-width">5</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>State_cont</ogc:PropertyName>
                            <ogc:Literal>state</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <MinScaleDenominator>3573</MinScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#FFFF00</CssParameter>
                            <CssParameter name="stroke-width">4</CssParameter>
                            <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>road_name2</ogc:PropertyName>
                        </Label>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <LinePlacement/>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>1</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">
                                    <ogc:Literal>#FFFF00</ogc:Literal>
                                </CssParameter>
                                <CssParameter name="fill-opacity">
                                    <ogc:Literal>1</ogc:Literal>
                                </CssParameter>
                            </Fill>
                        </Halo>
                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>                        
                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="maxDisplacement">800</VendorOption>
                        <VendorOption name="repeat">1000</VendorOption>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>
4
  • 3
    that isn't data it is trying to download it's the error message - look at the file or check the log and add the actual error to your question
    – Ian Turton
    Commented Jun 18, 2013 at 9:11
  • 2
    You also have to know that Geoserver does not currently support completely the SLD produced by QGIS... There is a version mismatch here that you have to take into account Commented Jun 18, 2013 at 12:31
  • @iant Thanks...I did not know that this file was an error report. That will help in resolving the issue.
    – GeorgeC
    Commented Jun 18, 2013 at 13:29
  • @iant -I just looked at the file and for some reason one of the attributes was renamed. Once I corrected this GS shows the correct symbology in the Layers--Properties--publishing--default style column but when you view the data, you can't see anything.
    – GeorgeC
    Commented Jun 19, 2013 at 0:09

2 Answers 2

2

QGIS produces SLD 1.1 while Geoserver only seems to support SLD 1.0 currently. The Geoserver blog indicates that they are working on it though, e.g. http://blog.geoserver.org/2013/02/26/geoserver-2-3-rc1-released/

1
  • -thanks. Can we downgrade QGIS to produce SLD 1.0. I had a look at qgis.org/api/… but it's not clear and I haven't implemented qgis python before.
    – GeorgeC
    Commented Jun 18, 2013 at 20:58
2

I had a similar problem in OpenLayers (wasn't using GeoServer) with an SLD 1.1.0 file from QGIS for a GeoJSON layer, but found a sloppy workaround via some find-and-replace magic in the SLD file:

  1. Changed beginning of file (xml prologue is it called??) to match 1.0 standards:

    <?xml version="1.0" encoding="UTF-8"?> <sld:StyledLayerDescriptor version="1.0.0" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" 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">

  2. Changed all instances of SvgParameter to CssParameter (credit to the suggestion at the end of this post).
  3. Changed all instances of <se:whatever>stuff</se:whatever> to <sld:whatever>stuff</sld:whatever> (this may have been just a QGIS feature, I am not sure).

Like I said, not pretty, but it allowed me to adapt a 1.1.0 SLD file exported from QGIS and then parse it in OpenLayers.

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.