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
0 votes
1 answer
35 views

Adding pixel-level classification to ee.ImageCollection

I am working with ee.ImageCollection('LANDSAT/LE09/C02/T1_L2') data pulled from earthengine-api in Python. I have previously defined a function to mask cloud, shadow, water, and snow. based on the ...
richard.turner's user avatar
0 votes
3 answers
43 views

ArcGIS Arcade code not giving desired outcome

I have the following code below. I'm trying to search for a text inside a string from a date field and populate it with the associated month with ArcGIS Arcade. So far I just keep getting the default ...
user avatar
0 votes
1 answer
54 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, ...
Androoo's user avatar
1 vote
2 answers
126 views

Use Trigger field with a calculation attribute rule to deleniate between auto calculated data and manually entered data

I have a calculation attribute rule in Arcade that is meant to have the following fields work in conjunction with each other: Name: eight digit unique ID AMPageName: 5 digit page name that consists ...
JBizz49's user avatar
  • 17
0 votes
0 answers
40 views

Get a list of fields from a list of shapefiles [duplicate]

I am trying to get a list of fields from every shapefile in a list I have created that's stored in a variable. My prof says I should be able to call that variable in my if/else statement within my for ...
hanbone's user avatar
  • 33
1 vote
1 answer
189 views

Using NDVI thresholds as a condition for successive elaborations in Google Earth Engine

From Sentinel-1 and Sentinel-2 it was created an image collection of 255 images, each with 5 bands: ndvi, VV_corr (VV corrected for the incidence angle), VV_diff (VV_corr difference between two ...
benedetta's user avatar
  • 138
0 votes
0 answers
48 views

Using if/else statement with unplaced labels in ArcGIS Pro

I am using ArcGIS Pro 3.0.1. I am planning on using maplex engine for labeling of tens of thousands of polygons. I would like to keep from transferring to annotation until absolutely necessary. I have ...
Simela's user avatar
  • 21
0 votes
1 answer
185 views

PyQGIS - If else statement

I want to run the calculation based on what the user chooses from the drop-down menu. For Example, if the user chooses the second option, then the calculation will be using the second formula. I can ...
Siti's user avatar
  • 27
1 vote
1 answer
481 views

Conditional statements with formulas in Google Earth Engine

I would like to apply an expression to an image based on conditions. The part of my code that I need to do this in is where i need to calculate runoff Q2 based on values of AMC and S: var runoff_func =...
Rozy's user avatar
  • 37
1 vote
0 answers
145 views

If/else custom script inside QGIS Modeler

I wanted to make a small if/else custom script inside the QGIS Modeler. I want the "Centroids" algorithm to be applied when the "L" field (created earlier in the "trees" ...
KyBik RyBik's user avatar
0 votes
1 answer
204 views

Using if/else statement in Google Earth Engine JavaScript API

I am studying because I want to publish my results through Google Earth Engine. Regarding the usage of if / else and ee.Algorithms.If(), I don't understand why both true case and false case work. As ...
YUHWAN SEO's user avatar
1 vote
1 answer
171 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 ...
Evgenii Shibkov's user avatar
0 votes
1 answer
203 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 ...
JackOfTales's user avatar
-2 votes
1 answer
681 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 ...
Olivia W's user avatar
2 votes
1 answer
233 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,...
Vadim's user avatar
  • 115
2 votes
2 answers
113 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 ...
Darren De Lange's user avatar
2 votes
1 answer
528 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 ...
Nikunj Pithva's user avatar
0 votes
2 answers
987 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 ...
hbk's user avatar
  • 434
1 vote
3 answers
5k 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 ...
Stephen Roy Gelling's user avatar
0 votes
1 answer
191 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 ...
Mehmet C ARSLANOGLU's user avatar
3 votes
2 answers
1k 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....
Rapu93's user avatar
  • 175
2 votes
1 answer
111 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 ...
Siddhartha Dhara's user avatar
5 votes
1 answer
3k 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 ...
Filip Strzinek's user avatar
6 votes
2 answers
2k 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. ...
Stevestingray's user avatar
2 votes
1 answer
41 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 ...
K_D's user avatar
  • 165
1 vote
1 answer
31 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 ...
Adam Zimmermann's user avatar
0 votes
2 answers
507 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....
cheff_'s user avatar
  • 139
1 vote
1 answer
134 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 ...
Kristen G.'s user avatar
  • 1,100
2 votes
1 answer
2k 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 ...
Therow's user avatar
  • 161
1 vote
1 answer
625 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): ...
kent 's user avatar
  • 101
0 votes
1 answer
333 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 ...
Schokoladenpudding's user avatar
0 votes
1 answer
363 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 ...
bkGeog's user avatar
  • 79
2 votes
1 answer
230 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 ...
klaus k.'s user avatar
  • 113
4 votes
1 answer
1k 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 ...
ar-siddiqui's user avatar
  • 1,748
6 votes
1 answer
9k 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 ...
Zihao Zheng's user avatar
-1 votes
1 answer
50 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 ...
user1503110's user avatar
1 vote
2 answers
296 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" ...
Bob's user avatar
  • 11
1 vote
0 answers
203 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 ...
Emmett McKinney's user avatar
1 vote
1 answer
1k 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 ...
geo_dd's user avatar
  • 604
1 vote
1 answer
638 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"...
Steve's user avatar
  • 773
2 votes
1 answer
417 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. ...
Lbook's user avatar
  • 51
1 vote
1 answer
499 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 ...
S. Price's user avatar
  • 311
1 vote
1 answer
391 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 ...
Cheekychives's user avatar
1 vote
1 answer
3k 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 ...
Felix Althén Bergman's user avatar
2 votes
1 answer
574 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 ...
tjwashin234's user avatar
1 vote
1 answer
76 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 ...
TobyG's user avatar
  • 21
2 votes
1 answer
137 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) ...
Laura's user avatar
  • 21
1 vote
0 answers
223 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 ...
Serena's user avatar
  • 13
2 votes
3 answers
3k 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), ...
Stevestingray's user avatar
2 votes
3 answers
2k 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 ...
Anahita Kp's user avatar