3

I have a problem while creating a model. I want to extract certain polygons based on a field value (chain of character). The problem is the name of the field might change depending on the origin of the vector layer (but the values are always the same: CD, CC, CC? and 5C).

In my model I put an entry of the model as "vector field", which allow me to choose a field from a vector layer (also an entry of my model), but when I write an expression in the "extract from attribute" algorithm (@Valueofhexagons='CD', with Valueofhexagons the name of my entry variable for the entry vectorfield) it does not extract anything.

When I type the name of the field (from a know vector file I am working on) "AltTB"='CD'... it works perfectly... but I have to change the name manually every time the name of the field change...which I would like to avoid if possible.

Any idea on how to use variables as entry model?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 19, 2021 at 22:36
1
  • Hi. Seems like you are using "Extract by expression" instead of "Extract by attribute" algorithm? Commented Jun 21, 2021 at 2:18

1 Answer 1

1

I little late but ...
I had a similar problem but solved it as soon as I posted my question. The variable is being used "as is" rather than as a field name to search in.

attribute(@SearchField) ilike concat('%', @SearchWord ,'%') solved my problem. The attribute() function gets the current value in the field of the name stored in @SearchField.

answered May 20, 2024 at 14:59

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.