I am working on a road dataset and would like to calculate a field(speed) using three conditional statements from two fields:
- formOfWay: with value, Dual carriageway etc.
- routeHierarchy: with values A Road, A Road Primary etc.
My aim is to return a speed value of 65 where formOfWay is Dual Carriageway AND Route Hierarchy is either A Road or A Road Primary.
Using the code provided in a similar question asked, I have tried the code below in ArcGIS Field Calculator, but haven’t been unsuccessful. The error message returned point to a syntax error in line 2 and I suspect this should be the part of the code having the two ‘routeHierarchy’
values (A Road and A Road Primary).
The code works with one coded value for routeHierarchy but returns an error when the second value is added.
def ifBlock(routeHierarchy, formOfWay):
if routeHierarchy == ['A Road','A Road Primary'] and formOfWay == 'Dual Carriageway':
return 65
else:
return 30
Please, can someone point out the correction I can apply to make this work?
if routeHierarchy in ['A Road','A Road Primary']
?