Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to use field calculator to compare two fields in a table of tax parcel data, Land Value (LAND_VAL) and Improvement Value (IMPRVT_VAL). My goal is to determine (1) Parcels with land value less than the value of improvements, (2)Land value about the same value as improvements, (3) Land value more than improvement value, but less than twice the value, and (4) Land value which is more than twice improvement value.

I wrote the following script, and it runs successfully in Field Calculator (doesn't give any errors), but it only returns 4, which is clearly not the case in the data.

LV = " !LAND_VAL! "
IV = " !IMPRVT_VAL! "

def Recode(Val_Analys):
    if LV < IV:
        return 1
    elif LV == IV:
        return 2
    elif (LV > IV and LV < (IV * 2)):
        return 3
    elif LV > (IV * 2) :
        return 4
    else:
        return 0

Recode(!Val_Analys!)

Any help would be much appreciated.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Just put this as the script code:

def Recode(LV, IV):
    if LV < IV:
        return 1
    elif LV == IV:
        return 2
    elif (LV > IV and LV < (IV * 2)):
        return 3
    elif LV > (IV * 2) :
        return 4
    else:
        return 0



Recode(!LAND_VAL!, !IMPRVT_VAL!)
share|improve this answer
    
Thank you! I need to practice python a bit more obviously. –  Chris Apr 9 at 23:08
1  
You're welcome. Easy mistake. –  ian Apr 9 at 23:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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