Tuesday, 19 July 2016

arcgis desktop - Reclass Using Field Calculator in ArcMap


I'm trying to reclass 3000, 2000, 1000 and 0.5 into 1, 2, 3 and 4 respectively in a new field using field calculator. However it keeps returning an error message and I can't figure out why, any ideas?


def Reclass( !BUFF_DIST! ):
if !BUFF_DIST! = 3000:
return 1
else if (!BUFF_DIST!) = 2000:
return 2
else if (!BUFF_DIST!) = 2000:

return 3
else:
return 4

Answer



Use Python parser and call the function with the actual field name enclosed in !!. BUFF_DIST=


Reclass(!BUFF_DIST!)

When you define the function use whatever name you want, for example buffdist. Also change = to == and else if to elif. Pre-Logic script code:


def Reclass( buffdist ):
if buffdist == 3000:

return 1
elif buffdist == 2000:
return 2
elif buffdist == 1000:
return 3
else:
return 4

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...