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

1
vote
2answers
46 views

Expression not saving in QGIS Field Calculator?

When I try to enter the following expression to remove NULLS, it does not appear to be saving/doing anything. if( "number" IS NULL, 0, "number") Open Attribute Table Open Field Calculator Check ...
0
votes
2answers
29 views

Reclassifying vector polygons based on text string to integer using Python Parser of ArcGIS Field Calculator?

So I am trying to reclassify a text string by searching for bits of strings and converting those strings to an integer value in a new field within the field calculator. e.g. I want to find all values ...
3
votes
1answer
48 views

How to run a Epanechnikov (parabolic) decay in QGIS 3.6 field calculator

Does anyone know how you would implement a Epanechnikov (parabolic) decay to a field in QGIS field calculator. I am trying to apply varying distance decay functions in order to assess the best ...
0
votes
1answer
33 views

ArcGIS Pro Field Calc to calculate pipe volume

I'm trying to do this calculation: (!DIAMETER!/2)*( !DIAMETER!/2)math.pi/144 !Shape.STLength()!*7.48 and keep getting an error. Can anyone give me the correct syntax for calculating the volume of ...
0
votes
2answers
78 views

QGIS how to fill the fields instantly and automatically when creating an entity

I have a polygon layer, I want to fill the fields automatically each creation of a polygon. Knowing that there is a spatial relationship (intersection, contain ...) between my polygons and other ...
1
vote
1answer
40 views

Map based on highest percentage from different variables

I've the 8 social classes (see under) for +- 900 polygons. I would like to create a new column that keep only name of the main social class for each row (based on the percentage). After that I would ...
1
vote
0answers
47 views

Getting error message in QGIS field calculator?

I have used an equation within the field calculator, that has previously worked in an older version of QGIS, I am currently using QGIS 3.6.2 the equation being: (atan((xat(-1)-xat(0))/(yat(-1)-yat(0))...
1
vote
1answer
41 views

Converting text strings to numbers using QGIS?

I am working in QGIS, which is quite new to me. I have a text string containing dates. I want to have new column where only the year from the text-date string appears. How is that possible. See ...
-1
votes
1answer
26 views

Using Field Calculator for subtracting values with same ID in ArcPy? [closed]

I have a line shapefile that used for some calculation. One of the calculation is subtracting values with a same group ID. The shapefile has a filed called LineID that consists of 2 lines with Side 1 ...
0
votes
0answers
30 views

Calculating field after arcpy.Append_management()?

I have some AutoCAD layers (f.e. Cad1, Cad2) and I want to export them into feature class in a geodatabase (f.e. feature_class). Also I want to calculate field in "feature_class" for objects from CAD. ...
0
votes
1answer
29 views

1:n relations in label expressions & general syntax

I've got a colleague who wants to create a (concatenated) label based on a 1:n relation between some shapes and related tables. They asked me if this was possible in QGIS - and I think it should. I ...
0
votes
1answer
32 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
30 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
30 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
44 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
92 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 ...
3
votes
1answer
142 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
33 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
85 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
86 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
52 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
60 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
42 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
102 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
43 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
61 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
69 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
36 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
36 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
24 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
55 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
27 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
63 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
100 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
43 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
80 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
60 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
27 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
148 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
55 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
137 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 ...