0

I have a stand alone application which reads SLD files, to draw something on a map canvas (development started under QGIS version 2.0.1). Unfortunally I have to deal with these old SLD files version QGIS 2.0.1 within a new context QGIS version 2.4.0 (security update Debian).

Is there a tool to migrate SLD files from 2.0.1 to 2.4.0?

Error or Warning?

Loading a style file that was saved with an older version of qgis (saved in 2.0.1-Dufour, loaded in 2.4.0-Chugiak). Problems may occur.

uname -a: Linux paprika 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u1 x86_64 GNU/Linux

/etc/debian_version 7.8

Sample BOR.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" 
  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>BORDER</se:Name>
    <UserStyle>
      <se:Name>BORDER</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Single symbol</se:Name>
          <se:PolygonSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#ffff00</se:SvgParameter>
              <se:SvgParameter name="stroke-width">0.35</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Sample BOR.qml

<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="2.0.1-Dufour" 
 minimumScale="0" 
 maximumScale="1e+08" 
 minLabelScale="0" 
 maxLabelScale="1e+08" 
 hasScaleBasedVisibilityFlag="0"
 scaleBasedLabelVisibilityFlag="0">
  <renderer-v2 symbollevels="0" type="singleSymbol">
    <symbols>
      <symbol alpha="0" type="fill" name="0">
        <layer pass="0" class="SimpleFill" locked="0">
          <prop k="border_width_unit" v="MM"/>
          <prop k="color" v="0,0,0,255"/>
          <prop k="color_border" v="0,0,0,255"/>
          <prop k="offset" v="0,0"/>
          <prop k="offset_unit" v="MM"/>
          <prop k="style" v="solid"/>
          <prop k="style_border" v="solid"/>
          <prop k="width_border" v="0.8"/>
        </layer>
      </symbol>
    </symbols>
    <rotation field=""/>
    <sizescale field="" scalemethod="area"/>
  </renderer-v2>
  <customproperties>
    <property key="labeling" value="pal"/>
    <property key="labeling/addDirectionSymbol" value="false"/>
....

Is it wise to change persistent production features, like settings of a map composition, within a major release?

  • Possibly barring vendor-specific tags SLD is not exclusive to any given version of QGIS. So, can you be more specific as to the nature of your error. Is the problem that your stand-alone application can't read SLD file produced in QGIS 2.4 or can QGIS 2.4 not read SLD files produced by the stand-alone software. It is not clear. – MappaGnosis Jul 27 '15 at 8:03
  • Hi, thanks for the question for precision. Our team produced the SLD's during the development process (starting in February 2014) with QGIS 2.0.1 and store the in stuff a settings directory, which is read by the app at start. When we update the DEBIAN repo's and recompile the app with QGIS version 2.4.0 an error or warning occurs when we standalone app again. To build a robust app it would be nice, to migrate SLD's and QML files by an non interactive tool which can be called by qmake or make. – huckfinn Jul 29 '15 at 10:14
  • What are the errors and warnings? It is difficult for anybody here to offer advice without knowing their exact nature. The reason I am pressing this is that I wonder if the SLD files in themselves are a bit of a red herring as it could be changes in the API (and nothing to do with SLD files) that is the root of your problem. – MappaGnosis Jul 29 '15 at 10:25
  • Loading a style file that was saved with an older version of qgis (saved in 2.0.1-Dufour, loaded in 2.4.0-Chugiak). Problems may occur. SMP Debian 3.2.68-1+deb7u1 x86_64 GNU/Linux; /etc/debian_version 7.8 – huckfinn Jul 29 '15 at 10:41
  • 1
    So, the problem does not lie with the SLD but the QML and the message is a warning rather than an error per se. SLD is not proprietary to QGIS and there is nothing in the SLD to identify the version of QGIS that created it ((and neither should it have) - which is my point. The QML, on the other hand, is proprietary to QGIS and does have a version identifier. To rectify that, simply check that your QML styles the data as expected and then re-save it in the new version. – MappaGnosis Jul 29 '15 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.