Hello,
I'm trying build a model to calculate a line feature with a conditional but it's not working and e it's returnig an syntax error at the expression line <return !shape.length@kilometers!/40*60>
I don't know what to do, can you guys give me a hand?
def Reclass(TIPO_PAV, CLASSIFICACAO 😞
if (TIPO_PAV=='ASFALTO' and CLASSIFICACAO=='URBANA'):
return 10000
if (TIPO_PAV=='TERRA' and CLASSIFICACAO=='URBANA'):
return 10000
if (TIPO_PAV=='TERRA'):
return !shape.length@kilometers! /40*60
if (TIPO_PAV=='ASFALTO'):
return !shape.length@kilometers!
else:
return 0
Looks like just a missing parenthesis. Your current code:
return !shape.length@kilometers! /40)*60
Should be:
return (!shape.length@kilometers! / 40) * 60
(I'm guessing?)
Oh No !!!
Even when I fix the parenthesis it keep the same error syntax.
I'd tryied to simplify the code just writing < return !shape.length@kilometers! > with or without parenthesis and keep returning the same error.
any other idea ?
If you open your Geoprocessing Results window you should see the failed calculator run. If you expand it and view the messages, does it provide any additional information?
After tryied many diferents ways to do it I've got this solution by using expression !shape.length@kilometers! in other field.
def Reclass(TIPO_PAV, CLASSIFICACAO,Distancia_Km 😞
if TIPO_PAV=='ASFALTO' and CLASSIFICACAO=='URBANA':
return 10000
if TIPO_PAV=='TERRA' and CLASSIFICACAO=='URBANA':
return 10000
if TIPO_PAV=='TERRA':
return Distancia_Km/40*60
if TIPO_PAV=='ASFALTO':
return Distancia_Km
else:
return "VERIFICAR"
Oh No !!!
Even when I fix the parenthesis it keep the same error syntax.
I'd tryied to simplify the code just writing < return !shape.length@kilometers! > with or without parenthesis and keep returning the same error.
any other idea ?