Run a model on every feature in the study area, with error logging

by EMDS Team

Iterates over each feature in the assessment's input layer and runs a Task. If any feature fails, the error is logged and execution continues. Replace the example task with your real engine + model via 'Configure with Wizard'.

πŸ—ΊοΈ ArcGIS Pro🌿 QGIS
Intermediate
for-looptry-catcherror-loggingper-featurebatch
{
  "id": "",
  "name": "Run a model on every feature in the study area, with error logging",
  "description": "Starter template: iterates over each feature in the assessment's input layer and runs a Task. If any feature fails, the error is logged and execution continues. Replace the example TASK with your real engine + model via 'Configure with Wizard'.",
  "version": 1,
  "steps": [
    {
      "id": "",
      "name": "Repeat for each feature",
      "description": "Iterates over every feature in your assessment input layer.",
      "step_type": "for_loop",
      "enabled": true,
      "continue_on_error": false,
      "config": {
        "loop_type": "each",
        "variable_name": "feature",
        "index_variable_name": "feature_index",
        "list_value": "{{study_area_features}}"
      },
      "children": [
        {
          "id": "",
          "name": "If something goes wrong, log it and keep going",
          "description": "TRY runs the model; if it raises, CATCH logs which feature failed.",
          "step_type": "try_catch",
          "enabled": true,
          "continue_on_error": false,
          "config": {
            "error_variable": "feature_error"
          },
          "children": [
            {
              "id": "",
              "name": "Run model on this feature",
              "description": "Click and use 'Configure with Wizard…' to pick your real engine + model.",
              "step_type": "task",
              "enabled": true,
              "continue_on_error": false,
              "config": {
                "engine_type": "",
                "model_reference": "",
                "input_source": "named_result",
                "input_variable": "feature",
                "store_result_as": "feature_result"
              },
              "children": [],
              "else_children": []
            }
          ],
          "else_children": [
            {
              "id": "",
              "name": "Log the failed feature",
              "description": "",
              "step_type": "log",
              "enabled": true,
              "continue_on_error": false,
              "config": {
                "level": "warning",
                "message": "Feature index {{feature_index}} failed: {{feature_error}}"
              },
              "children": [],
              "else_children": []
            }
          ]
        }
      ],
      "else_children": []
    }
  ]
}
An unhandled error has occurred. Reload πŸ—™