All Questions
Tagged with python-parser if-else
25 questions
0
votes
1
answer
71
views
Field Calculator If Statement
I am new to python and was trying to populate a decade field based on an if else statement on another field that contains parcel years.
The code block is below:
def ifBlock(Parcel_Year_Built, ...
-2
votes
1
answer
921
views
Writing IF THEN string calculation in ArcGIS Pro [closed]
I am attempting to calculate a text field in my attribute table based on a number code given in a different column
For example, any number under the "LU_1" column that is '510' will be ...
0
votes
2
answers
580
views
ArcGIS Pro Python Field Calculating
I am trying to use Python in ArcGIS Pro to cleanse some data via imported Excel sheets. The expression works, but the Code Block if-else statement to return nothing if !Street_Id! is returns an error....
2
votes
1
answer
3k
views
Writing If-Then Statement in ArcGIS Pro Field Calculator Code Block using Python Parser
I have two columns in my shape file with text values called GP and Z which contain abbreviations and a third column called UpOrDown which is meant to hold the binary 0-1 generated from the if-then ...
1
vote
1
answer
753
views
Why does Python if/else statement only return else condition when trying to reclassify field using ArcMap field calculator?
Using ArcGIS 10.4. I'm trying to reclassify values from a field (ECOREGION_DIVISION), which is in string format, into new values using the following Python syntax:
def Reclass(ECOREGION_DIVISION):
...
-1
votes
1
answer
58
views
What does if-else code do?
I just started a new job and in one of the procedures I was given for one of my tasks I found this piece of code. It just adds a comment to a field that's already filled up. For instance, field1 might ...
1
vote
2
answers
360
views
Filling attribute tables with values from the same attribute table
Just wondering if there's an easy way to fill null values in one column in an attribute table with values in another column of the same attribute table by just writing a query "just the "null values" ...
1
vote
0
answers
212
views
Reclassifying string variable in ArcGIS Field Calculator with Python Parser?
I am trying to calculate a roadway pedestrian restriction based on its functional class, using if/else logic in Python. Every time I enter this, it only turns up 'No'. The categories are strings, and ...
1
vote
0
answers
232
views
Using IF-Statements in Calculate Field Code Block inside an Iteration
I have created a model in ArcGIS 10.2 that iterates through some feature classes in order to add a field 'Zmin10' (double) and calculate the field value based on a variable (called "Minimum") to which ...
2
votes
3
answers
3k
views
Using IF/ELSE Statement for field calculation in ArcPy?
I would like to calculate the slope value in %, but I don’t want to have any negative values. If there are negative values in the slope field, I would like to multiple them by -1 and if not, multiple ...
2
votes
1
answer
394
views
Calculating field on if-else-condition checking input parameters for <Null>?
I want to calculate a field depending on 3 input string parameters. Two of them can contain Null-values. My old VB expression was not able to work with Null-values, so the script stopped.
Now I want ...
2
votes
1
answer
7k
views
Writing If-Then statement in ArcGIS Pro field calculator using Python?
I've been using ArcGIS Pro over ArcMap recently because ArcMap is giving me some incorrect summary statistics that I use to populate a data field in a number of feature classes. The problem is that I'...
1
vote
1
answer
4k
views
Field calculator to calculate if field contains certain text
I have a field (WS_Type in the screenshot) that I want to use to calculate values based on the text within the field. The number of occurrences of each WS_Type in the field is not important, but the ...
1
vote
4
answers
1k
views
Using ArcGIS field calculator with if else to populate field?
ArcMap 10.4.1 on Windows 7.
I am trying to fill in some blank rows in a column using field calculator. The field I am trying to fill is: label. If it is empty I want it to be populated with a value ...
1
vote
2
answers
913
views
Python syntax error with If/elif statement in field calculator when using concatenation
I am unsure what syntax issue I am having with my If/Elif statement. I want to not use a column in my calculation if the value is blank. The end goal is to not have extra spaces before, after and ...
6
votes
1
answer
5k
views
Writing Python code block in field calculator?
I am a novice in Python as well has having minimal experience with ArcMap. Currently I am using a U.S. Census TIGER file, mapping roads in Harris County, TX. I want to add a new field called SPEED, ...
0
votes
1
answer
134
views
Field Calculator: Simple Python If-then and maths
I want to take all positive values in a field and multiply them by -1000. To do this, I put together the following code block:
def myCalc(x):
if (x > 0):
x*(-1000)
return x
else:
...
1
vote
1
answer
277
views
Creating If Then statement in Field Calculator between 2 values? [closed]
I have a FC with a column for NEAR_ANGLE from the output of the NEAR tool. The angle is displayed in degrees (i.e. -154.67687) which is fine. I am trying to create a column, HEADING, that reads this ...
1
vote
1
answer
798
views
Field Calculator Odd IF Statement?
I am working on a street addressing project.
I want to add a number to every odd number.
Example if [field] is odd [field]+=1.
How can I do this in ArcMap using the field calculator.
I used to work ...
-1
votes
2
answers
3k
views
If Then Else Statement in Field Calculator using Python - ArcGIS 10.1
I am trying to populate a field [Hazard] based on the values in two other fields [Depth2D] and [Speed2D].
I have managed to write a code block in VB script that works but I really want to figure out ...
1
vote
1
answer
183
views
Using an IF statement in Field Calculator
I'm trying to use an if statement in the field calculator:
This is what the code looks like in Python:
a= 2
FacilityID= !FACILITYID!
if a%2==0:
MH_ID_Calc=FacilityID[0:6]
else:
MH_ID_Calc=...
1
vote
0
answers
148
views
If/Else Statement in Python ArcGIS Field Calculator [duplicate]
I have a shapefile and want to calculate a field based on another field. The two fields are "DURATION" and "STATUS". I need "STATUS" to display three different outputs based on "DURATION". I want "...
8
votes
2
answers
1k
views
Performing multiple calculations in ArcGIS Attribute Table?
I have an existing Excel spreadsheet developed to track specific fire hydrant data, this is periodically updated and joined to the spatial hydrant data in ArcGIS. In the spreadsheet there is a number ...
6
votes
1
answer
990
views
Classifying time periods in new field using Python Parser of ArcGIS Desktop?
I have a datetime field (Horario) in my feature class, showing only the time. Although the date doesn't appear, it seem to be stored automatically as 30 Dec 1899, I'm not sure why.
I want to use ...
6
votes
1
answer
41k
views
Writing conditional (if/then) statements into ArcGIS Field Calculator using Python Parser?
I have gotten stuck on seemingly simple ArcGIS field calculator python expression.
I obtained a great answer to a another similar question a few years ago: Using Range in Python expression of ArcGIS ...