I'll begin by stating I am very new to the python world!
My problem is this....
I am trying to use field calculator in ArcGIS Pro to return a calculation of values in other fields based on an if statement, if that makes sense! Not sure if it can be done?
The Calculation is
Qrp=Sum(Qs*Ls)/SumLs
Basically thus;
weightAADT(!rp!,!Qs!,!Ls!)
Code Block
def weightAADT(rp, Qs, Ls):
if rp=="Urban Two Lane":
return sum(Qs * Ls) / sum(Ls)
my error is "TypeError: 'float' object is not iterable"
Any help appreciated
Fair enough Dan, I'll try and explain...
I have a database with 525 entries, which I will call 'sites'. Each site has a 'RP' field with 1 of 4 possible attributes, i.e. Urban Two Lane, Rural Two Lane etc.
I need to carry out a calculation, based on the RP attribute, that returns the sum of [Length of site (Ls) * Traffic Flow @ site (Qs)] divided by sum Ls.
So a calculation needs to be applied to each site belonging to a defined RP, before summing up for that RP, if that makes sense.
Below is a very simplified version of fields and attributes contained in said database
Site_ID | Ls | Qs | RP |
R125 | 1.25 | 4445 | Urban Two Lane |
R148 | 0.98 | 8956 | Rural Two Lane |
R524 | 1.35 | 2350 | Urban Two Lane |
R385 | 0.88 | 10253 | Urban Dual Carriageway |
R449 | 1.01 | 15236 | Rural Dual Carriageway |
R621 | 1.1 | 1052 | Urban Two Lane |
To be fair Dan I have used the summarise feature followed by a join to get the required result, my query was if there was a better way of doing it in Pro with field calculator alone.
better way... no... only way... yes …. well, except for doing it in numpy from the start and producing the summary result table directly, but that would be a parallel solution
Thanks Dan