I have two layers: Data
and Thresholds
. Data
is a point vector layer (GeoPackage) that has hundreds of fields. Thresholds
is a csv table with three threshold values for each field. My goal is to create a new field in Data
that would be a classification value. I need to check if any value of a feature in Data
exceeds the threshold value of the same field in Thresholds
. For example, if any Data
value exceeds the first threshold value in the corresponding field in Thresholds
, the classification value would be 1. Or if it exceeded the third threshold value, the classification would be 3. So I will have to loop through the values in Thresholds
for each field in each object in Data
. A couple nested loops, no biggie here.
The way I want to do this is to take the name of the field in Data
and check if there is such a field in Thresholds
. If there is, then I will loop through the field and change the value in Data
. It is possible that in the future, Data
will contain fields that are not in Thresholds
.
How do I get access to a fields name, and how do I get access to a field using just the name?
layer.fields().field("my_field_name")
. See the docs.