Run a model only if the layer has more than N features

by EMDS Team

Counts features in the input, then only runs the model if the count exceeds a threshold. Edit the threshold in the IF step.

πŸ—ΊοΈ ArcGIS Pro🌿 QGIS
Beginner
set-variableif-elseconditionalthreshold
{
  "id": "",
  "name": "Run a model only if the layer has more than N features",
  "description": "Starter template: count features in the input, then only run the model if the count exceeds a threshold. Edit the threshold in the IF step.",
  "version": 1,
  "steps": [
    {
      "id": "",
      "name": "Remember the minimum feature count",
      "description": "",
      "step_type": "set_variable",
      "enabled": true,
      "continue_on_error": false,
      "config": {
        "scope": "local",
        "operation": "set",
        "variable_name": "min_features",
        "value": "10"
      },
      "children": [],
      "else_children": []
    },
    {
      "id": "",
      "name": "Only if feature count > minimum",
      "description": "Replace {{feature_count}} with a real count source.",
      "step_type": "if_else",
      "enabled": true,
      "continue_on_error": false,
      "config": {
        "variable_name": "feature_count",
        "operator": "greater_than",
        "expected_value": "{{min_features}}"
      },
      "children": [
        {
          "id": "",
          "name": "Run model",
          "description": "Configure with Wizard… to pick the engine + model.",
          "step_type": "task",
          "enabled": true,
          "continue_on_error": false,
          "config": {
            "engine_type": "",
            "model_reference": "",
            "input_source": "assessment",
            "store_result_as": "result"
          },
          "children": [],
          "else_children": []
        }
      ],
      "else_children": [
        {
          "id": "",
          "name": "Log: skipped — not enough features",
          "description": "",
          "step_type": "log",
          "enabled": true,
          "continue_on_error": false,
          "config": {
            "level": "info",
            "message": "Skipped: only {{feature_count}} feature(s), need more than {{min_features}}."
          },
          "children": [],
          "else_children": []
        }
      ]
    }
  ]
}
An unhandled error has occurred. Reload πŸ—™