2

I have a polygon dataset and I would like to label the area of all polygons which have "kamer" in the column "type".

I tried some expressions but I get different Errors. Two examples of what I tried is the following:

Function FindLabel ( [Area], [type] )
  if ([type] = 'kamer') then
   FindLabel = UCase([Area])
  end if
End Function

This gives me the following error:

The expression contains an error.
Modify the expression and try again.
Error 1 on line 16.
Syntaxisfout.

Another expression I tried is:

def FindLabel ([Soort_kamer], [Oppervlakte]):
  if int([Soort_kamer]) = 'kamer':
    return [Oppervlakte]
  • 2
    Welcome to GIS.SE. If you say "I tried something" please make sure to include your trials in your question. – Erik Dec 10 '19 at 13:34
  • 2
    Could you also add to your question what goes wrong. Can't get it to work is a bit vague. – Berend Dec 10 '19 at 13:46
2

You have to use double quotes in your if statement

Function FindLabel ([Area], [type])
  if ([type] = "kamer") then
    FindLabel = UCase([Area])
  end if
End Function
1

There are two problems with this line of the Python version:

if int([Soort_kamer]) = 'kamer':

Firstly, it is comparing an integer to with a string. Secondly it is using the assignment operator (single =) not the equality comparator (double ==).

Assuming the 'Soort_kamer' field is actually a string field, that line should be:

if [Soort_kamer] == 'kamer':
  • Thanks, I overlooked the int in this code, I fixed it now and used the equalty comparator – Jan. Dec 11 '19 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.