2

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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 5, 2019 at 12:44
1
  • 1
    You first check if the field name exists like here: gis.stackexchange.com/questions/299263/… And then, if the index is different to -1, you can access the field using layer.fields().field("my_field_name"). See the docs. Commented Nov 5, 2019 at 12:52

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.