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
1answer
45 views

Can't copy field to another: 'Empty value for Objectid = 0'

I tried to copy a field with dates that had type 'TEXT' to a new column of type 'DATE' because it is not possible to change the initial type of the original field. arcpy.CalculateField_management(r'...
0
votes
2answers
28 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 ...
3
votes
2answers
12k views

How to fill the column in attribute table with same values in QGIS?

I have about 19000 records, I added new column and I would like to fill it with string values (eg. brand)- same value for all rows. I'm not considering copy/paste. I know I could do it with ...
1
vote
1answer
111 views

Comparing rows value of same field in QGIS?

I have a field in attribute table names "Route", with rows I want to comapre row one of Field"Route" with row two of the same field if the value bigger or smaller then insert a value in another ...
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 ...
2
votes
3answers
2k views

Automatically assigning numbers to point file in various order in QGIS?

I know how to automatically assign numbers to a new point files using the $rownum function in the field calculator. However it does it from the top-left over and down like reading a book. I could ...
1
vote
1answer
39 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 ...
2
votes
2answers
325 views

Performing Conditional Calculate Field with Many to One using ArcMap?

Anyone have experience calculating a field based on a many to one scenario? I have a feature class in a geodatabase with a field of unique names. Feature Class Table (let's call this "MAINTABLE") ...
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. ...
6
votes
1answer
633 views

Classifying time periods in new field using Python Parser of ArcGIS Desktop?

I have a datetime field (Horario) in my feature class, showing only the time. Although the date doesn't appear, it seem to be stored automatically as 30 Dec 1899, I'm not sure why. I want to use ...
6
votes
1answer
3k views

Writing Python code block in field calculator?

I am a novice in Python as well has having minimal experience with ArcMap. Currently I am using a U.S. Census TIGER file, mapping roads in Harris County, TX. I want to add a new field called SPEED, ...
8
votes
2answers
708 views

Performing multiple calculations in ArcGIS Attribute Table?

I have an existing Excel spreadsheet developed to track specific fire hydrant data, this is periodically updated and joined to the spatial hydrant data in ArcGIS. In the spreadsheet there is a number ...
1
vote
1answer
132 views

Making output shapefile taking fields of input, and adding new field populated with list using PyQGIS?

I found a couple of good answers like here for example, but I do not manage to adapt them and make them work... What i am trying to do: take the input, create new output with same fields, add a new ...
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 ...
1
vote
1answer
210 views

Vector Fields as Input Variable in Field Calculator

I’m working with QGIS 3.2 Bonn and I try to build a workflow in the graphic modeler. The model aims to build variable buffers depending on values from two attribute fields of an input vector layer. ...
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 ...
3
votes
1answer
91 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
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 ...
10
votes
1answer
1k views

Auto incrementing field based on groups within feature class?

I am needing to auto increment a field based on groups within a feature class. I have 8 plots within a given polygon and I need to assign them an ID from 1-8 for each set of plots within each polygon. ...
14
votes
1answer
26k views

Using Elseif Conditional Statement in QGIS Field Calculator?

I am trying to write an ELSEIF conditional statement in QGIS Field Calculator (version 1.8.0). I have used an example I found online: CASE WHEN val < 0 THEN 'negative' WHEN val = 0 THEN "neutral'...
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
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 ...
8
votes
2answers
3k views

Making automatic updated date and time field in QGIS?

I want to make a date and time updated field as I edit an attribute field in this format yyyy-mm-dd 00:00:00 (= 2016-05-08 11:04:00) - my local date/time. The data is in a QGIS 2.14 shapefile and ...
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 ...
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 ...
5
votes
1answer
2k views

Extracting Derived Z-coordinate data

I am trying to extract the z coordinate value from the derived attributes, similar to How to re-calculate area, perim, p2a,width and length in QGIS? but I cannot see a dedicated operator for finding ...
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?...
1
vote
4answers
329 views

Calculations in if statement

I want to perform a simple calculation with the Field Calculator using this piece of script (note that all the elif statements are attempts for another syntax and non of the worked): def change(...
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 ...
1
vote
2answers
249 views

Azimuth from last point to next point

I found an script on https://community.esri.com/blogs/dan_patterson/2016/09/01/distance-calculations-using-the-field-calculator but the script is giving the azimuth to the next Objectid point and what ...
70
votes
4answers
143k views

Calculating polygon areas in QGIS?

How do I calculate areas of an area shapefile in square meters or in acres (ha)? I didn't find that functionality in the vector tools.
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/...
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 ...
2
votes
1answer
9k views

Calculating Area of Raster Classes using ArcGIS Desktop?

I have a raster in a GRID format that was created by Image Classification. The GRID is projected in StatePlane meters, but I would like the area in square feet. I'm assuming I will need to use the ...
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....
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 ...
3
votes
1answer
136 views

Referring to Null value with ArcPy Expressions?

How do I refer to Null values in a field using an expression in Python? I've tried using the following as well as = None and =Null but nothing has worked yet: ScoreCondition = "Cond_Score(!"+...
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 ...
22
votes
3answers
9k views

How to refer to another layer in the field calculator?

Is there a way to select an attribute from a polygon layer and insert the value into a virtual field of a point layer using "within" in the field calculator? CASE WHEN within($geometry, ...