Questions tagged [if-else]

An if-else statement is a programming conditional statement that runs a different set of statements depending on whether an expression is true or false.

Filter by
Sorted by
Tagged with
1 vote
1 answer
42 views

If/else statement in Google Earth Engine doesn't give output desired

I am trying to make a correction for the NDVI index calculated from Sentinel-2 using GEE. I found out that for pixels with NDVI meaning in the range (0.5, 0.6) it should be subtracted 0.122..., and ...
user avatar
0 votes
0 answers
27 views

ArcGIS Pro If / Else Python Labeling Expression - Formatting

I'm using ArcGIS Pro and am trying to recreate this label expression using formatting rather than concatenating, as I've read it is more efficient / faster. I can't seem to wrap my head around how to ...
user avatar
0 votes
1 answer
23 views

When to Update Row within an Update Cursor that uses multiple if statements for different fields?

I have a model that requires a stupid number of conditional statements. The older version was utilizing feature layers, select by attributes, and Calculate fields many, many times. I rewrote it to ...
user avatar
-2 votes
1 answer
65 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 ...
user avatar
0 votes
0 answers
46 views

Conducting 'if' conditional and 'for' loop in Google Earth Engine

I'm going to conduct if conditional and for loop in Google Earth Engine. However, the process is completely different to other programming language such as MATLAB. I know about ee.Algorithm.IF and map ...
user avatar
  • 11
2 votes
1 answer
65 views

Calculate geometry in IF/ELSE statement using ArcGIS.Pro field calculator

I'm using If/else statement to calculate geometry (field "LENGTH") for features meeting special criteria (the value in "TYPE" field does not equal AB201, AB202, AB203, AB204, AB205,...
user avatar
  • 91
2 votes
2 answers
102 views

Script removes all data from fields when using custom function in Field calculator

I am trying to clear entries in columns using the field calculator but with my current script, it removes all the data from all the rows. Basically, if the Historical column is equal to 'Historical ...
user avatar
0 votes
0 answers
67 views

The expression my image value is showing null in Google Earth Engine

Using the if/else in the expression how to call the value of image as E in the code. After putting the expression value the E value as a image is showing 0 value. How to get image value in the ...
user avatar
2 votes
1 answer
133 views

IF ELSE statement for expression using Google Earth Engine

Code link: https://code.earthengine.google.com/a2c5293fff598d37ccb7843bff8bc27d In this expression, the value of 'E' is derived from the image. All other values come from the asset table. So I wanted ...
user avatar
0 votes
2 answers
168 views

Create list of shapefiles names from shapefiles in a folder, if folder does not contain shapefile type, print a statement stating this [closed]

I am creating a list of shapefiles names from files in a folder: items = os.listdir(r'E:/folder/test') print('checking directory...') print('your files are: ') print() filenames = [] for names in ...
user avatar
  • 413
1 vote
3 answers
1k views

ArcGIS Pro arcade if else statements

I am tasked with sorting Zoning codes numbering over 100 to just 5 (Residential, Office, Commercial, Industrial and Misc). For whatever reason I cannot get Arcade to recognize a text attribute other ...
user avatar
0 votes
1 answer
82 views

Using expression operators in if/else conditions without getInfo in Google Earth Engine

İ have a two-segment list with id and value and i want to make a new list from imageList using second element value. i want to get the first values in first column until 100 in second colum and save ...
user avatar
3 votes
2 answers
449 views

If statement in Python QGIS Raster Calculator

I would like to perform a raster calculation with the if condition and I wrote this code: import qgis import gdal from qgis.analysis import QgsRasterCalculator, QgsRasterCalculatorEntry from qgis....
user avatar
  • 165
2 votes
1 answer
82 views

Composite band through Batch processing using Sentinal 2 data in arcpy

As we know sentinel satellite data have many sub folder. I want to create composite band of each datasets with the band 2, band 3, band 4, band 8 which are located in one folder(10m) and band 11, band ...
user avatar
4 votes
1 answer
652 views

Using conditions in Graphical modeler QGIS 3.10.5

I have a question about my model which is quite complex. I have two types of line INPUT and the model will not be executed unless one of the line INPUT is empty. The problem is with a tool 'Snap ...
user avatar
6 votes
2 answers
629 views

Nested if statement in QGIS label expression

I'm trying to create labels for features, based on the value (or missing value) of three different columns and combinations can be possible. I have three columns: Veg_dom, Veg_codom and Veg_onderg. ...
user avatar
2 votes
1 answer
37 views

How does gridmetrics handle IF condition in user defined functions?

I noticed a kind of "inconsistency" in the values returned from two user-defined functions. I tested on a tile of 200mx200m to return a raster of pixel size 50m (16 pixels) In the following ...
user avatar
  • 155
1 vote
1 answer
29 views

ArcMap labels that come from different fields

I am trying to make labels for a feature class called m_GraveLotSingle. I have a field that is called "Raised_Flat". If the field is "RAISED" I would like it to show the label of ...
user avatar
0 votes
2 answers
186 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....
user avatar
  • 129
1 vote
1 answer
91 views

Carto: Can I use some “if/then/else” structure in popup custom HTML?

I believe I am asking a question similar to this question that was asked a few years ago about popup functionality in the old CartoDB. I just tried my best to replicate the solution to that question ...
user avatar
  • 1,060
2 votes
1 answer
850 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 ...
user avatar
  • 153
1 vote
1 answer
289 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): ...
user avatar
  • 101
0 votes
1 answer
190 views

ArcGIS Pro field calculator if - else - string error

I try to calculate some fields with the field calculator using a simple if-else condition. I would like to write the values in the field volume, based on some calculations including values of fields ...
user avatar
0 votes
1 answer
131 views

How to use if else statement to create attribute in shapefile using R [closed]

I am working on a if statement within R to populate a new variable called d1 with values from my income field if variable A equals 1, otherwise autofill zeros. I'm having issues with getting it to ...
user avatar
  • 69
1 vote
1 answer
148 views

Using Python Code from QGIS modeler with if and else

I am using QGIS 3. The following script code is generated from a model. At the end the code has to create a field Fl_m2, if the blnFl is true. if ['blnFl'] is True: If it is not true the ...
user avatar
4 votes
1 answer
448 views

Using Boolean Parameter in QGIS Graphic Modeler

I am trying to create an if/else condition with a boolean parameter in QGIS graphic modeler. The parameter will be used inside Field Calculator2 algorithm.By default the parameter is False. I am ...
user avatar
  • 1,385
6 votes
1 answer
4k views

Using if/else structure in Google Earth Engine

I wrote some simple code to test the if/else structure in GEE: var flag = ee.Algorithms.IsEqual(1,5); print(flag) if (flag) { print("this is true"); } else { print("this is false"); } the output ...
user avatar
-1 votes
1 answer
48 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 ...
user avatar
1 vote
2 answers
159 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" ...
user avatar
  • 11
1 vote
0 answers
146 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 ...
user avatar
1 vote
1 answer
687 views

Simple condition on rasters with different extents, R

I have multiple raster objects, with the same resolution but slightly different extents. I have use the following function in order to reclassify them and now their values are between 1-6. What I ...
user avatar
  • 584
1 vote
1 answer
428 views

Setting up if/then/else for choice of two options or boolean in ArcGIS ModelBuilder?

I'm using ArcGIS Desktop 10.6 and have a model as shown in the image below. I'm calling it option 1. The model exports GIS data to CAD DWG format and is comprised of two submodels, "Setup" and "Export"...
user avatar
  • 721
2 votes
1 answer
221 views

Using if statement with ArcPy and GetCount?

I am looking to get a count on the polygonNieghbor and if it has polygons in it then I want to move to the next step MakeFeatureLayer. and If it doesn't have any features I would like it to finish. ...
user avatar
  • 51
1 vote
1 answer
299 views

Enabling model tool even if field already exists using ArcMap ModelBuilder? [duplicate]

I made a quick little tool in ModelBuilder to add specific fields based on a precondition (checked boxes). The issue I'm having is that if any of those fields already exist in the feature I'm trying ...
user avatar
  • 307
1 vote
1 answer
276 views

Using a wildcard in an elif statement in pyscript...?

I’m trying label up a blank field with ‘yes’ or ‘no’ to the presence of names with either the word ‘Estuary’, ‘Loch’, or ‘Firth’ using * as a wildcard, in Field Calculator. I think I'm getting mixed ...
user avatar
1 vote
1 answer
2k views

ee.Algorithms.If throwing both cases in Earth Engine

I'm trying to work with the ee.Algorithms.If in the sense that: if list = 0(i.e. not containing any points within a buffer) -> do a function() else (buffer is containing points)-> do a function() My ...
user avatar
2 votes
1 answer
183 views

Checking for the existence of a workspace (arcpy), issues with if else statement

I am trying to describe, list, and test for existence of featureclasses in a geodatabase using the following code. import arcpy #Set geoprocessing environments arcpy.env.workspace = "C:"" #Check if ...
user avatar
1 vote
1 answer
60 views

How to write Python if/then statement using information from two fields in field calculator

I am using ArcGIS Desktop 10.6.1. I create a new field of type short integer in the Attribute Table. My new field is named CIPOT and I want to populate it with values from the field CI, but only if ...
user avatar
  • 21
2 votes
1 answer
114 views

Simplifying variable (if condition) with field calculator in QGIS

I want to simplify the variable ("SIOSE_CODE") which has values like this: A(90MTRfr_05PST_05SDN) A(65PST_35MTRfr) A(70FDCfr_10PST_10MTRfr_05MTR_05SDN) The first number (here 90 resp. 65, resp. 70) ...
user avatar
  • 21
1 vote
0 answers
164 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 ...
user avatar
  • 13
2 votes
3 answers
2k views

Writing label expression with ArcMap and If then Statement?

I am having problems with label expression in ArcMap 10.2.1. I want to show two labels per polygon, but only when there are two labels to show. Every polygon has at least one label (Veg_Dominant), ...
user avatar
2 votes
3 answers
1k 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 ...
user avatar
2 votes
1 answer
285 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 ...
user avatar
  • 23
2 votes
1 answer
2k views

conditional statements for raster in R - land surface temperature

Im trying to calculate Land surface temperature estimating with Landsat 8 images, but i got stuck in one place and i cant move on. I m following split window algorithm. I calculated NDVI and I have ...
user avatar
0 votes
1 answer
169 views

Using If Then Else statement against selected records in ArcPy?

I am working on a Python script that will count how many selected features there are and if there are it will make a feature layer from them. If the script runs and finds there are 0 selected records ...
user avatar
  • 1,377
2 votes
1 answer
6k 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'...
user avatar
1 vote
1 answer
2k 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 ...
user avatar
  • 63
1 vote
4 answers
570 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 ...
user avatar
  • 452
1 vote
1 answer
384 views

Checking field type in ModelBuilder using if else?

I am creating a model in gis ModelBuilder. I want to check the type of a particular field and if it is long integer than the tools should be different and else (i.e. not a long integer) my tools ...
user avatar
1 vote
2 answers
818 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 ...
user avatar