Python code block

377
1
Jump to solution
03-14-2022 03:00 PM
JoshaAnderson
New Contributor
 
0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

Hello, 

I want write a python code block using " geoprocessing calculate field that adds a text field to the roads.shp feature class called FERRY. This new field should be populated with values of YES and NO depending on the value of the FEATURE field. If the value of the FEATURE field is ‘Ferry Crossing’, the value of the FERRY field should be YES – otherwise the value of the
FERRY field should be NO.

 

if this is a field calculation, with "a" containing the data and "b" being updated

 

def calc(a):
    """ """
    if a == "Ferry Crossing":
        return "YES"
    return "NO"

 

 

python parser

expression calculating into field "b"

calc(!a!) 

Where the field name (a) is enclosed in !

You can use this code block and expression in CalculateField 


... sort of retired...

View solution in original post

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

Hello, 

I want write a python code block using " geoprocessing calculate field that adds a text field to the roads.shp feature class called FERRY. This new field should be populated with values of YES and NO depending on the value of the FEATURE field. If the value of the FEATURE field is ‘Ferry Crossing’, the value of the FERRY field should be YES – otherwise the value of the
FERRY field should be NO.

 

if this is a field calculation, with "a" containing the data and "b" being updated

 

def calc(a):
    """ """
    if a == "Ferry Crossing":
        return "YES"
    return "NO"

 

 

python parser

expression calculating into field "b"

calc(!a!) 

Where the field name (a) is enclosed in !

You can use this code block and expression in CalculateField 


... sort of retired...
0 Kudos