8

Is it somehow possible to convert a QGIS 2.x processing model (*.model) to a *.model3 so I can run them in QGIS 3.0 without having to redo mine from scratch?

1

1 Answer 1

8

I fear there is no simple way to convert geoprocessing models from QGIS 2 to 3. Simply converting it from json to xml can be done with services like http://www.utilities-online.info/xmltojson/ but the structure of the result is completely different between the two versions:

Converted from QGIS 2 model json (example):

<?xml version="1.0" encoding="UTF-8" ?>
    <values>
        <inputs>
            <network>
                <values>
                    <pos>
                        <values>
                            <y>458</y>
                            <x>296</x>
                        </values>
                        <class>point</class>
                    </pos>
                    <param>
                        <values>
                            <isAdvanced>false</isAdvanced>

                            <name>network</name>
                            <shapetype>1</shapetype>
                            <default />
                            <value />
                            <exported />
                            <hidden>false</hidden>
                            <optional>false</optional>
                            <description>network</description>
                        </values>
                           <class>processing.core.parameters.ParameterVector</class>
                </param>
            </values>
            <class>processing.modeler.ModelerAlgorithm.ModelerParameter</class>
        </network>

QGIS 3 model (native xml)

<!DOCTYPE model>
<Option type="Map">
  <Option name="children" type="Map">
    <Option name="native:buffer_1" type="Map">
      <Option value="true" name="active" type="bool"/>
      <Option name="alg_config"/>
      <Option value="native:buffer" name="alg_id" type="QString"/>
      <Option value="Buffer" name="component_description" type="QString"/>
      <Option value="382" name="component_pos_x" type="double"/>
      <Option value="447" name="component_pos_y" type="double"/>
      <Option name="dependencies"/>
      <Option value="native:buffer_1" name="id" type="QString"/>
      <Option name="outputs" type="Map">
        <Option name="result" type="Map">
          <Option value="native:buffer_1" name="child_id" type="QString"/>
          <Option value="result" name="component_description" type="QString"/>
          <Option value="582" name="component_pos_x" type="double"/>
          <Option value="492" name="component_pos_y" type="double"/>
          <Option value="" name="default_value" type="Unknown"/>
          <Option value="false" name="mandatory" type="bool"/>
          <Option value="result" name="name" type="QString"/>
          <Option value="OUTPUT" name="output_name" type="QString"/>
        </Option>
      </Option><!DOCTYPE model>

Apart from the fact that the two structures have very little in common, the processing environment and the modeler have undergone extensive changes (additional/changed input parameters and algorithms). So my conclusion is that we have (sad but true...) to manually convert our QGIS 2 models to the new environment.

2
  • Sad ... Is that still the last word or is there a solution now?
    – MartinMap
    Commented Oct 15, 2018 at 7:11
  • @MAP apparently it is. so i redid mine of which i had just four at that time anyways. For that one large model which actually made me post the question i used a 2.14 installation on a spare machine. An automated conversion might still come in handy for others but i assume that since it wasn't that much of a hustle for me as expected initially the demand is not high enough.
    – maxwhere
    Commented Dec 18, 2018 at 15:21

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.