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 [field-calculator]

Use for questions about Field Calculators of QGIS, ArcGIS Desktop, etc and their Calculate Field tools

0
votes
1answer
20 views

Expression returning wrong value in QGIS Field Calculator?

My QGIS Field Calculator expression: case when "field_value" = '' or "field_value" <> NULL then (if( "field_value" = '', 'N', 'Y')) end returns null value even if "field_value" has something ...
0
votes
0answers
22 views

Field calculator not working with division command

Really do not understand what is up. I am able to sum two columns, but unable to divide them. I selected out any entries with "0". Nonetheless, a simple division command in the form of ([a]+[b])/[...
0
votes
1answer
26 views

Auto Incrementing Field based on Selection of Records in Feature Class?

I'm attempting to write a script that will add an incremented value to a field based on a selection of records. For example, the script will select the first 300 records in a feature class and then ...
1
vote
0answers
37 views

Reprojection puzzle

Initially, my question was about strange results in area calculations in QGIS. I got bigger results for planimetric calculations - using area($geometry) - compared to ellipsoidal calculations - using $...
3
votes
1answer
76 views

Date formating in QGIS using expression?

My expression: day(now()) || '/' || month(now()) || '/' || year(now()) returns current date as 15/4/2019, but I want to get the date in dd/mm/yyyy format i.e. 15/04/2019. How can I get that using ...
0
votes
0answers
14 views

Computing 2 fields on basis of 3rd field and getting output in new field? [on hold]

I have a situation in which I want percentage agriculture area in Field Column "F_Agriculture" by computing Field "Area" divided by field "Area_m2", if field "LandusesSt" is equal to "Jordbruksmark". ...
3
votes
1answer
120 views

Expression for random numbers without duplicates

Using only the QGIS field calculator, how to create an expression that generates random numbers without duplicates? rand (1,10) and randf (1,10) generate random numbers but could be repeated in a set ...
1
vote
1answer
31 views

Calculating field from three conditional statements

I am working on a road dataset and would like to calculate a field(speed) using three conditional statements from two fields: formOfWay: with value, Dual carriageway etc. routeHierarchy: with values ...
4
votes
1answer
83 views

Update Cursor skipping last row?

I have created a python function within field calculator to calculate the time difference between a timestamp (yyyy-MM-dd HH:mm:ss) in a row and the row after (the interval field in seconds). I have ...
0
votes
4answers
79 views

Copying/replacing first letter in column of attribute table in ArcMap with field calculator and Python Parser? [closed]

How to copy / replace the first letter in a column if that letter is "N" and replace with "C" in the field name "DISTRICT" inside the attribute table in ArcMap using Python inside the field calculator?...
0
votes
1answer
50 views

Python Script is repeating results

I have developed a python script to copy and paste in the field calculator. Having an input of three values, it compares all of them and returns a list of unique values. The problem is that when I use ...
3
votes
1answer
36 views

How to extract the maximum value from an array in the QGIS Field Calculator?

I'm trying to get the maximum value from an array, using the max() function. The syntax for the max() function is this: max(value1,value2…) I have an array: [ 1, 2, 3, 4, 5, 6, 7, 8 ] which I got ...
0
votes
0answers
16 views

Sum calculation in Field Calculator using Python script [duplicate]

I have a problem with Python script in Field Calculator. How to sum the values of one field ('AB') and paste the sum in another field ('RE') using Python in Field Calculator? I'm working in ArcMap 10....
3
votes
1answer
34 views

Calculating acreage as a percentage in ArcPy

I am struggling to calculate the acreage as a percentage in Calculate Field Management, but I am getting this error message: "ValueError: could not convert string to float! BufferAcreage! arcpy....
2
votes
0answers
67 views

Advanced Python Field Calculator - QGIS Processing Toolbox

I'm trying a very simple task. I want to write the layer name in a new attribute column. I managed to do this using Field Calculator. But I need to do the same for a lot of files in batch mode, only ...
0
votes
1answer
53 views

Using If/Then Statement in ArcGIS Field Calculator?

I am trying to add a column that shows vegetation production (numeric) in relation to soil series. I have each soil series already in the attribute table however I am having a hard time writing the if/...
1
vote
2answers
39 views

Use a python expression in Field Calculator to sum each row across several columns

this seems like it should be easy but I am new to python and am having trouble... I have four columns. I would like perform a field calculation that sums the values by row for three of the columns and ...
1
vote
2answers
57 views

Selecting latest date with QGIS field calculator?

My shapefile contains columns like "Street", "number" and "date". What I want to do is, to find the latest date (where we have done house services). If we have 2 dates for one house number ("number")...
3
votes
2answers
57 views

QGIS how to sum a certain vector field inside a polygon and populate a field in the polygon?

I have a polygon with vector point civic addresses inside it. Each civic address has a different number residence. I want to sum the total number of residence inside that polygon and it populate a ...
1
vote
1answer
29 views

Reclassifying field using Python wildcard string search?

I have a point layer with 900K Tree Point records. In that layer I have field (d_Species) that contains the tree species of each record. I've created a field (SpecieValu) to assign a value (0-3) for ...
2
votes
2answers
34 views

Get DD Lat and Lon from CRS EPSG:3111 - GDA94

I have a shapefile in CRS EPSG:3111 - GDA94 that I am trying to generate Lat and Lon, however when I use the field calculator and try to populate the lat lon I am getting values that I can't use as ...
0
votes
0answers
20 views

How to trim cell values in an attribute field

I am working in ArcMap 10.4.1 and need to trim cell values in the NAME field of a feature class. Everything starting from double underscores needs to be deleted. This is my attempt in Field Calculator....
0
votes
2answers
35 views

Splitting string ID code into various parts

I have a series of identification codes that I need to split out. The format of these codes is [region(letter)][district(number)] - [place(number)][subdistrict(letter)]. An example of some codes ...
1
vote
1answer
21 views

Calculate field tool doesn't stop running because of codeblock in ModelBuilder?

I am running the following model, which seems to work and populate the added field that I want, but the final calculate field doesn't stop running even though it seemed to do what it should. The point ...
3
votes
1answer
17 views

Calculate a field using text from another field separated with comma

I have an address field containing the following text: "64,ramkoti,hyderabad,500070" I need to copy hyderabad to another field. What would be the code used in the field calculator tool to achieve ...
2
votes
2answers
53 views

Understanding arcpy.CalculateField_management with Join?

I am using arcpy.CalculateField_management to fill a column field with another column values. I have two shapefiles, fishnet.shp and new_run.shp. First I joined both using arcpy.AddJoin_management as ...
1
vote
1answer
26 views

Prioritising values in accordance to various Columns

I previously asked for help in Prioritizing the Attribute table of a self made polygon layer Prioritising polygons in QGIS Now I want to change this prioritisation in accordance to multiple values ...
1
vote
0answers
45 views

Field Calculator not Allowing Decimal Numbers (QGIS 3.6) [closed]

QGIS version 3.6 When creating new virtual fields in shapefiles, the field calculator does not allow the output field length or precision to be changed. These are both greyed out except for when ...
1
vote
0answers
65 views

Getting QGIS processing script field calculator error?

I have a processing script that I created for QGIS 3.4.5 but I keep getting the following error: Traceback (most recent call last): File "", line 66, in processAlgorithm File "C:/PROGRA~1/QGIS3~...
1
vote
1answer
41 views

Autoincrementing one character in calculate field of ArcGIS Pro?

I am using ArcGIS Pro. I have this set of points where I like an unique id (uid). The only thing they need to be unique is a counter of some sort at the end. I have another field with some id that ...
2
votes
1answer
20 views

Modify script so only empty fields are changed in ArcGIS Pro?

I currently use a script that converts the integer in OBJECTID to a string and combines it with another string (in this case UAW,) to populate a field Field = str(!OBJECTID!) + "UAW" Now that I have ...
0
votes
0answers
35 views

Converting Text Field to Numeric in ArcGIS Pro?

I'm trying to convert text to numeric, but am unable to in ArcGIS Pro. Is there a Python function? I tried int(!FieldName!) but I think NULL values are messing it up?
0
votes
2answers
47 views

Remove duplicate strings from a field with Field Calculator in ArcGIS

I tried using the same codeblock in this post: Remove duplicates from a field, but it is just copying the contents and not removing duplicates. I think my data is formatted the same. Anyone see what I'...
1
vote
1answer
22 views

Using Python Lists in Calculate Field Code Block? [closed]

I'm looking for some help in explaining what exactly is occurring with the following code: MaterialLife = "LifeMaterial(!"+Material+"!)" codeblock2 = """def LifeMaterial(mat): material = {"ABS":...
2
votes
2answers
124 views

Calculating multiple fields using ArcPy?

I have found a script that can add multiple fields to my existing shapefefile. Now, I need to add to my existing script so that it will calculate the new fields that have been added. In most cases, ...
0
votes
1answer
28 views

Combine Two Fields Into One

I joined two tables to a shapefile and the output table has a field from each. Both fields represent the same thing so I'd like to combine them into one. You can see a clip of my fields below, where ...
3
votes
1answer
53 views

Python time condition within Calculate Field

I am attempting to assign 0/1 values to each row with a point feature class based upon a time dependent condition with ArcMap Model Builder 10.2.2. The points are categorized based upon a series ID ...
2
votes
1answer
23 views

Splitting ID number along hyphens and creating new field with only parts of ID In Field Calculator?

I have a shapefile with polygons and each polygon has an ID number that follows a pattern like this: SMP_ID 1077-1-1 8-2-2 1281-1-3 304-2-1 In have created a new field and I need to populate it ...
3
votes
1answer
127 views

Use intersection in field calculator

I want to use the tool intersects in the field calculator. If the condition is true, I want to set a result field to a specific number. The field calculator doesn't accept my expression but I can not ...
1
vote
1answer
42 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 ...
2
votes
2answers
142 views

Using Python in field calculator to extract highest value from 3 columns [closed]

I have three columns, one for percentage White, percentage Hispanic, and percentage African American per census tract. I'm trying to use Python to extract the population subtype with the highest ...
1
vote
1answer
54 views

QGIS working with a point and polygon layer

I have 2 layers, layer A ( point data) and layer B (polygon data). Within layer A I want a column which will indicate Yes or No if a polygon is within 500m. I have created a 500m buffer for layer b ...
0
votes
1answer
37 views

Using Calculate Field tool to make empty field be populated with adjacent field's data?

I have about 80 species of birds with at least about 100,000 records each. I used the iterator tool to create a field named [Count] for each species, but now need the empty field to be populated with ...
2
votes
2answers
32 views

Calculate field does not update using ArcPy

I want assign 33 if the field no_apt is zero and 34 if no_apt is any else value. The model run without any error, but no value are assigned the field GGV_kW. What is wrong with the code since it doesn'...
3
votes
1answer
59 views

How to re-use an expression, stored as a string, in QGIS Field Calculator

As discussed in this question, QGIS automatically saves recently used expressions in the field calculator. But recently used expressions are deleted after a while. Sometimes I need to re-use an ...
4
votes
1answer
160 views

How do I get this query to work in the field calcuator in QGIS 3.2?

I have a geopackage file which contains point data with column of 'depth of cover' and score. In the score column I am using the field calculation to create an expression so that any number less than ...
2
votes
0answers
58 views

Extract features in .gdb file based on their attributes

I have a .gdb file with >17,000 features. Simplified example of attributes table: ID NAME DATE ETC 0001 london 2012 12 0002 london 2012 23 0003 thame 2012 45 0004 ...
2
votes
1answer
64 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) ...
3
votes
2answers
124 views

Extracting substring from field in ArcMap using Python Parser of Field Calculator?

I have some parcel data where I need to extract a subdivision name from a long string. The format is always "Subdivision: ____ ______ _____" etc. BUT, there is no uniformity to what comes before or ...
1
vote
1answer
56 views

Argument 1 has unexpected type 'set' Error using processing in QGIS?

I am currently working on a code that adds a field to a shapefile and inputs its filepath. I understand that the processing.run has changed from qgis 2 to qgis 3 but I am not sure why I am getting ...