1

In ArcGIS Desktop 10.1 I created a new field to explain some zoning codes in an attribute Table. I basically want the new field "Zone" to have a string value based on the field "Zoning".

For example if the "Zoning" field value is "AG" then the corresponding "Zone" field should be "Agricultural".

I can do this easily in an Excel Sheet and bring it back to a Layer by a join, But I really want to know if there is a way to do this either with Python or VBScript using the Field Calculator.

The code may be something similar top the one below.

If [Zoning] = "AG" Then 
[Zone]= "Agricultural"
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
AlMazar
  • 11
  • 1
  • 2
  • 2
    See http://gis.stackexchange.com/questions/21916/using-conditional-statements-in-field-calculator?rq=1 http://gis.stackexchange.com/questions/52930/arc-10-python-shp-attributes-usings-fields-to-populate-other-fields-if-then?rq=1 http://gis.stackexchange.com/questions/52930/arc-10-python-shp-attributes-usings-fields-to-populate-other-fields-if-then?rq=1 – Antonio Falciano Oct 17 '13 at 14:02
  • Have you looked at using subtypes? That might be another way of doing it. http://resources.arcgis.com/en/help/main/10.1/index.html#//005r00000001000000 – KiloGeo Oct 17 '13 at 18:24

1 Answers1

2

This should be fairly simple to do using the Python parser in Field Calculator. Right click on the [Zone] field header and select Field Calculator.

In your Pre-Logic Code block, put something like:

def zone_type(zone):
    if zone == "AG"
        type = "Agricultural"
    elif zone == "other zone"
        type = "other type"
    elif zone == "other zone" # Repeat for each additional zone
        type = "other type"   # and zone type
    return type

In your other code block, you should have something like:

Zone = zone_type(!Zoning!)
Barbarossa
  • 5,797
  • 27
  • 61
  • Thanks for your answer. I tried several times (few combination of different syntax) but it is not working – AlMazar Oct 17 '13 at 14:23
  • Here is my Code ( pre-logic and code block) def zone_type( zone ): if zone == "AG" type = "Agricultural" elif zone == "C1" type = "Neighborhood Commerciall" elif zone == "MF-1" type = "Multi Family" # and zone type return type

    zone_type(!Zoning!)

    – AlMazar Oct 17 '13 at 14:25
  • The links provided by @afalciano are useful resources as well. – Barbarossa Oct 17 '13 at 14:33