Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [if-statement]

An if statement is a programming conditional statement that, if proved true, performs a function or displays information.

1
vote
1answer
81 views

Using if statement in Google Earth Engine?

I'm new to GEE and and having problems to create an if statement with .contains(). Using I let the user create a point in the map using onClick. I have a polygon layer with fire areas. If the point ...
1
vote
0answers
25 views

Checking Shapefile type (Point, Line, Polygon) in ModelBuilder using python script?

I am creating a model and would like the input to branch off to different tools within the model based on the shapefile type (point, line, polygon). I haven't found a tool in ModelBuilder that will do ...
0
votes
1answer
35 views

Using an SQL Query to skip or run a code in ArcPy/ Python

Using ArcMap 10.4 and Python I am trying to run a code (arcpy.ExportReport) on a bunch of different frequency tables. Which I have completed the only problem is that if I have a table that does not ...
1
vote
1answer
53 views

Using ArcGIS Calculate Field with condition?

I have a point feature class which has two fields for two different sets of geographic coordinates (called "GPS_LON", "GPS_LAT" and "SHIFT_LON", "SHIFT_LAT"). I want to calculate the approximate ...
1
vote
1answer
66 views

If/Then Statement in ArcMap to Remove Duplicates [duplicate]

I need help writing an if/then statement in ArcMap 10.5. Scenario: I generated a near table, but since the closest features (polylines) were mostly all overlapping with the input (multipoints), the ...
0
votes
1answer
351 views

If/Then Statement with LIKE using the Field Calculator

I cannot get the below to work with a LIKE variable within the If/Then statement. Is there something that I am missing? Prelogic Script dim y If [Categories] LIKE '%Orange%' Then y = "Medium" Else ...
1
vote
2answers
348 views

Using field calculator if statement to update another field using another field's values?

Using VBA in field calculator I am trying to figure out the expression that if 3 conditions are met populate a field using another field's value and I cant get it to work! CALC_CLASS is a joined table ...
0
votes
2answers
54 views

Return values from combining different fields

I'd like to classify parcels according to combinations of front setbacks and side setbacks. I have a "Fr_sb" field with values 0 (no front setback) and 1 (with front setback), and a "Si_sb" field with ...
0
votes
1answer
229 views

if-then statement using VBscript not working

I'm trying to reclass from the value of field using if then statement. the statement is like this.. In the figure above, what is making the result not work on my ArcGIS?
0
votes
1answer
119 views

Several IF statements with Indentation error

I wrote a very long "if statement" script but something doesn't work. It returns several Indentation errors but I cannot understand where...could be something else? from PyQt4.QtCore import * from ...
1
vote
1answer
256 views

Remove first character from a string if it satisfies an if statement [closed]

I have a bunch of phone numbers and some contain a 1 in front of them e.g. "18885556607" and I would like to simply remove the 1. I can't just remove all first characters because there are numbers ...
3
votes
3answers
489 views

Using IF statement in FOR loop? [closed]

I'm trying to use a for loop in a list to assign different buffer widths to the list depending on the length of the line being buffered. I have my list of lengths, and tried to use a for loop to ...
4
votes
1answer
2k views

Why are QGIS field calculator statements (both IF and CASE) giving strange results?

Using the field calculator, I'm trying to update an attribute only if it equals to zero: CASE WHEN "Z" = 0 THEN "Z" = rand(1,100) END This let the 0 values as they are and updates all others to "...
2
votes
1answer
410 views

Conditional statement ENVI

I am trying to do conditional statement in ENVI to calculate multiband image: result = (b1)^2 - (b2)^2 if (b1 eq 0) or (b2 eq 0) result * 0 else result * (result gt 0.0) Is there a way to combine ...
1
vote
0answers
65 views

Checking for the presence of a particular field in ModelBuilder [closed]

The model that I'm now building in ModelBuilder will take as an input a certain feature class that may, or may not, have a certain field. I would like the model to check for the presence of that field ...
1
vote
1answer
74 views

Multiple calculations with if then statements and NULL values

I'm trying to calculate a total demand in ArcGIS 10.2.2, stored in fields Demand1, Demand2, ... , Demand20. Some of them contain a numeric value. The others have a <Null> value. The sum ...
1
vote
1answer
313 views

Using ArcGIS Feature Compare in ArcPy?

I am trying to write a script partially in ArcGIS ModelBuilder and adding an if statement on my own. It uses the Feature Compare tool in arcgis and I want to use the result.getOutput in an If ...
0
votes
1answer
216 views

Parsing error with in ArcPy code

I have the following code in Python for a tool I want to build. For some reason I viewshed don't exist in the folder I have chose (out). Also when I am trying to define the output workspace every time ...
0
votes
2answers
219 views

Understanding if-else statements in ArcGIS field calculator when coded value domain used?

I am attempting to set a newly created field based on the strings in another field 'TNMFRC'. I am pretty sure that I have the code write, and yet everything is set to a value of '6'. Here's my code: ...
2
votes
1answer
232 views

How to create an if statement for moving data if a cell is blank from another column

I need help creating an if statement for moving data from one column to another if it is blank. Any suggestions? See screen shot for highlights noting the data that needs to be moved (po boxes).
-5
votes
1answer
176 views

Using if statement with ArcPy? [closed]

Can somebody help with me with my if statement code on the bottom? try: # Import the modules import arcpy from arcpy import env # Set up the environment env.workspace = r"C:\...
4
votes
2answers
10k views

If-Then Label Expression

I'm trying to create a VB label expression on streets such that streets with an alternate name (ACS_ALIAS) will be labeled with the LABEL name and the alternate name in parentheses; streets with no ...
4
votes
2answers
2k views

Writing If-Then Statement in ArcGIS Field Calculator using Python Parser?

Scenario: I have four fields: A, B, C and D Field A is text-based and contains values from '000' up to some number 'xxx' Field B contains a set of values (also text, but represented by numbers) ...