Field Calculator
field_calculatorAdd a missing field and populate it with a QGIS expression per feature, updating values in place. Returns updated and failed counts, preserving old values on error.
Instructions
Add (if missing) + populate a field from a QGIS expression, per feature, in-place. field_type: string|int|double|bool|date|datetime (default double). Example: expression='$area', field_name='area'. $area/$length use the project's ellipsoid and units (reported back as 'measurement'), not necessarily m2/m; the area()/length() functions are planimetric in the layer CRS (measurement.planimetric_units, squared for area()); length() of a string counts characters and reports no units. Returns updated and failed counts; failed features keep their old value and first_error says why. Refused while the layer has an open edit session.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| length | No | ||
| layer_id | Yes | ||
| precision | No | ||
| expression | Yes | ||
| field_name | Yes | ||
| field_type | No | double |