4

i'm trying to export my symbols from Qgis as an SLD file to use it as a style for the layer in geoserver here is an example of my SLD:

<?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" units="mm" 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>stclines_streets</se:Name> <UserStyle> <se:Name>stclines_streets</se:Name> <se:FeatureTypeStyle> <se:Rule> <se:Name>Single symbol</se:Name> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#d575ef</se:SvgParameter> <se:SvgParameter name="stroke-width">0.26000000000000001</se:SvgParameter> <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter> <se:SvgParameter name="stroke-linecap">square</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> <se:LineSymbolizer> <se:Stroke> <se:GraphicStroke> <se:Graphic> <se:Mark> <se:OnlineResource xlink:type="simple" xlink:href="ttf://Dingbats"/> <se:Format>ttf</se:Format> <se:MarkIndex>65</se:MarkIndex> <se:Fill> <se:SvgParameter name="fill">#ff0000</se:SvgParameter> </se:Fill> </se:Mark> <se:Size>2</se:Size> </se:Graphic> <se:Gap> <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"> <ogc:Literal>3</ogc:Literal> </ogc:Filter> </se:Gap> </se:GraphicStroke> </se:Stroke> </se:LineSymbolizer> </se:Rule> </se:FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor>

this doesn't work for any complex multi symbols like lines with graphical hashes and so. even when i try using Qgis plugin " geoserver explorer " to publish it the published SLD file ignore that multi symbols or font symbol at all however when i go to SLD cookbook and take some code samples for some complex symbols but in v 1.0.0 it kinda works, but i need the advanced options in GUI that QGIS has.

i read in that thread that QGIS produce 1.1.0 while geoserver validate 1.0.0 SLDs but i'm looking for an update for that issue or is it still ?thread link

  • 1
    What's the error or error message? – bugmenot123 Sep 6 '16 at 11:56
  • multiable errors including the headers and tags names was expected to be in v 1.0.0 for example <se:whatever>stuff</se:whatever> was expected as <sld:whatever>stuff</sld:whatever> or the tag name itself example: CssParameter instead of se:SvgParameter, i think it's all about about the version differences from 1.1.0 to 1.0.0 , but Qgis does not export and 1.0.0 so any work around that ? – Ibrahim Mohammed Sep 6 '16 at 12:00
9

Current QGIS releases export invalid SLD 1.1 in various ways. In your example, you should amend the gap this way:

<se:Gap>3</se:Gap>

There are also other issues like wrong sizes and the custom usage of the mark index, that no released version of GeoServer can handle (but it's already in, GeoServer 2.9.2 will have that improvement).

Future versions of QGIS will have less of these problems, we made some fixes and improved compatibility during the FOSS4G 2106 code sprint, which will end up in QGIS 3.0 (backport pending, not ETA at the moment). See my recent summary mail here: http://osgeo-org.1560.x6.nabble.com/FOSS4G-code-sprint-idea-improving-SLD-export-and-GeoServer-compatibility-tt5273812.html#a5283626

  • ok so as i understand there is no way to produce complex symbologies other than following the SLD standards for 1.0.0 and do the edits by hand, is there any other software than Qgis that have same capabilities and can export valid SLDs? i have tried uDig but not that advanced as Qgis. – Ibrahim Mohammed Sep 6 '16 at 12:37
  • 3
    No, you can also use SLD 1.1, but it has to be correct, the one generated by QGIS is not, at the moment (but it's improving). uDig can indeed generate SLD 1.0 that is also with GeoServer. I'm not aware of other open source software doing the same. – Andrea Aime Sep 6 '16 at 12:52
  • Ok thank you Andrea for the clear answer, i hope this issues get solved in future updates. – Ibrahim Mohammed Sep 6 '16 at 12:55
3

I had to adapt many complicated, hundred of clases simbology sld made in qgis to be used in Geoserver some time ago. I tried some programs with no luck, so finally I changed a few things in the QGis sld file to make it work in Geoserver.

Basically it´s just 3 steps, using the "search and replace" tool:

1- i replaced the first line with one from an existing geoserver sld:

2- Also copy the first lines raplacing the "****" with your own

<sld:NamedLayer>
         <sld:Name>****** </sld:Name>
               <sld:UserStyle>
                    <sld:Name>*****</sld:Name>
                    <sld:Title>******</sld:Title>
                    <sld:Abstract>******</sld:Abstract>
                      <sld:FeatureTypeStyle>
                        <sld:Name>name</sld:Name>

and do the same with the closings

                           </sld:FeatureTypeStyle>
                    </sld:UserStyle>
            </sld:NamedLayer>

3- Use the search and replace tool: replace <se: and </se: with <sld: and </sld: respectivly. And replace SvgParameter with CssParameter

Sorry if i don´t use correct vocabulary, i´m not so much into coding, neather into english language. Please someone improve my answer.

A co-worker made a script to do the steps before automatically with RStudio and made it even simpler for me.

This was a good enough work-around for me and solved my problem. Probably now there´s a better way (i hope so). I share anyway in case it helps you.

  • What version of QGis and Geoserver is this workaround for? – geoA Dec 6 '17 at 18:28
  • 1
    I did it on QGis 2.14 and Geoserver 2.7. Now i´m using Qgis 2.18 and Geoserver 2.9 and still works. I think from geoserver 2.12 there´s no need to do this any more. – A_NeriWinter Dec 6 '17 at 18:30

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.