Questions tagged [field-calculator]

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

Filter by
Sorted by
Tagged with
72
votes
4answers
151k 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.
29
votes
3answers
22k views

Filling column with consecutive numbers in QGIS?

I make a new column in my attribute table and it has a default value (for example 0). I want to (probably using the field calculator) have the result that row 1 has the value 1, row 2=2 and so on, ...
24
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, ...
17
votes
3answers
90k views

Basic If/Then in Python Parser of ArcGIS Field Calculator?

I am using ArcGIS 10.2 for Desktop, and I've been looking through this site, and can't seem to figure out my answer yet. Very new to VBA and Python, but lots of years with ArcGIS. I know I can do ...
16
votes
3answers
10k views

Calculating sum of parts of column based on another column using QGIS Field Calculator?

I would like to calculate the sum of values in one column, based on values in another column. To illustrate my question I uploaded the picture below. The second column consists of zipcodes, the third ...
16
votes
3answers
28k views

Rounding column in attribute table using ArcGIS Field Calculator?

I want to use the Field Calculator in ArcMap to round an existing column to two decimals. Currently I have a column that is 6 decimal places long and would like to simply round it down to 2 decimals. ...
15
votes
3answers
26k views

Creating Conditional Statement in QGIS Field Calculator

I've looked up some of the other Q&As on this topic, however, none have addressed what I am seeking to do. I have a large data set and I would like to search one field for any values over a ...
15
votes
7answers
9k views

Find/Replace Double Quotes using Python Parser of ArcGIS Field Calculator?

I'm trying to use the Field Calculator (ArcMap 10.0) to strip out double quotes in an address field (I didn't put them in there, believe me). I've tried many incantations but am still unable to even ...
14
votes
5answers
18k views

Concatenating fields in field calculator of QGIS?

Is there a way to concatenate fields in field calculator of QGIS? (e.g. hectares + ' ha')
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'...
13
votes
4answers
6k views

Extracting number of vertices in each polygon?

I have ArcGIS Desktop 10.2 and my challenge is how to extract the of number vertices in each polygon for all features like this: I have many parcels in my feature class and I want to extract the ...
13
votes
1answer
22k views

Calculate area within Python script in ArcMap

I am trying to calculate the area of a polygon within my Python script. I create a new polygon from merging two together, and I'd like to add the area of the resulting polygon to a field in the output ...
13
votes
8answers
33k views

Removing return/newline (\n) character from Field using Python and Field Calculator?

I have a geodatabase table with a field that I'm trying to remove return characters (new line). I found this post (How can I remove (chomp) a newline in Python?) of how to do it, however it is not ...
12
votes
1answer
299 views

QGIS, Populate field with self-updating formula (like spreadsheet)

Is there any way (plugin, or otherwise) to put a formula as the value of a field, which would then self-update as the other fields it is based on are adjusted? Exactly the way field-calculator updates ...
12
votes
1answer
13k views

Syntax of conditional statements in QGIS Field Calculator(s)

I have a shapefile which I need to modify. There is one column "CLASS" with the attributes: "A", "B" and "C". I need to change "A" into "1", "B" into "2" and "C" into "3". I tried it with case when ...
12
votes
2answers
9k views

Converting from DMS to DD using Python in Field Calculator?

I need to convert lat/long that is expressed as degrees, minutes, and seconds in the data into decimal degrees. For example, in the data, they are listed as N335042.06 in the Latitude column, and ...
11
votes
3answers
19k views

How to use the replace string function in Field Calculator?

Within an attribute table I'm trying to replace one string with another using the 'replace' function . As an example, there are a number of features whose field 'NAME' contain the string '(B)' and I'...
11
votes
2answers
3k views

Is there a way to assign row number for sorted table by column in QGIS?

Field calculator has a great function under "Records" called "$rownum" which returns (assigns) the number of the current row. Is there a way to make it work together with sorting? Lets say I want to ...
11
votes
3answers
7k views

Calculating sequential numbers into sorted table using ArcGIS Desktop?

Is there a way to calculate a sorted field with sequential numbers? I have seen Sorting feature class to calculate sequential ID field using ArcGIS Field Calculator? that outlines how to calculate ...
11
votes
2answers
1k views

Computing new attribute based on changes in another attribute using ArcGIS Desktop with Python?

I am attempting to classify a set of gps time-encoded point data into behaviors based on different attributes. I have created an attribute that is 0 for home and 1 for away based on location, and ...
10
votes
4answers
802 views

Need to find strings that contain the same word twice

I have attribute data with owner names. I need to select data that contains the last name twice. For example, I may have an owner name that reads "BENNETT MCCARL & ARNETTE BENNETT". I would like ...
10
votes
1answer
1k views

Obtaining specific part of string from field in QGIS attribute table?

I'm having a bit of trouble here with this situation. I want "NumeroCamp" only to have the numbers are showing in "Text". Is there any function in field calculator that could help me with that?
10
votes
1answer
18k views

How to perform If Statement in Field Calculator of ArcGIS for Desktop?

I have a shapefile containing two numeric fields ("Dist_1" and "Dist_2"). I want a Field Calculation that will populate an additional field ("Result") with one of three answers: First if Dist_1 is ...
10
votes
7answers
72k views

Extracting raster DEM elevations to vector attribute tables in ArcGIS Desktop?

I have an ArcMap 10 project with multiple layer groups. One layer is a raster DEM, another layer group is a bunch of vector shapefiles (including points, lines and polygons). The client wants all ...
10
votes
1answer
505 views

QGIS-Custom functions not showing in Field Calculator

I'm using Essen and trying to follow Anita Graser's wonderful tutorial Illuminated contours. I've created the azimuth function and loaded it but there is nothing showing in the expression tab - not ...
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. ...
10
votes
2answers
684 views

Using wildcards for column headers in QGIS Field Calculator?

I know you can use wildcards for fields like so (in the Field Calculator): case when "column" ILIKE '%example%' then 1 else 0 end Can you do something similar for the column headers themselves? I ...
10
votes
1answer
764 views

Undo field calculation in ArcGIS Pro?

I am using ArcGIS Pro and cannot find a way to undo field calculations. With ArcGIS 10.x for Desktop, field calculations could be undone when an edit session was active, but Pro seems to be in a ...
9
votes
4answers
7k views

Removing numeric characters from alphanumeric value in field calculation?

I have a field containing alphanumeric values in the following format: A-AA00 Sometimes they are also A-AAA0 I need a Python script I can put in the field calculator in ArcMap 10 that will at ...
9
votes
3answers
8k views

Using Field Calculator in QGIS to update columns with centroid coordinates

In QGIS I would like to update two columns with the centroid easting and northing of my polygons. I am using the field calculator. I have tried using $x and $y but this only seems to work for points. ...
9
votes
5answers
18k views

Adding file name to attribute field using Calculate Field?

Does anybody know how to add the shapefile name to a field in the file's attribute table? I've found a description: 'You have to use inline variable in CalculateField like %Name% in expresssion ...
9
votes
2answers
3k views

How to find if polygon has a hole using field calculator in ArcGIS

Some 3rd party software cannot handle polygons with holes (donut polygons). To find them I always use ArcView 3 field calculator, because: however when I try to do this in ArcGIS, I get this: So the ...
9
votes
6answers
7k views

How to create a label formatted like “ 1,000' ” from a numeric field?

This question builds on a previous question I came across at gis.stackexchange: How to easily edit attribute data using Regular Expressions? Perhaps someone can point me in the right direction? I ...
9
votes
4answers
1k views

Getting ArcGIS to include leading zeros in text field?

I am entering characters in a text field that is essentially a 5 number ID. I need leading zeros to be included in the value, but every time I enter or calculate the field, the leading zeros are ...
9
votes
2answers
1k views

Splitting text from a string field before each delimiter to new fields

I'm trying to extract text data from a string field containing text delimited by dots and placing it in new fields using the field calculator. Im using this python function (Taken from How to extract ...
9
votes
4answers
424 views

Saving Equations used in QGIS Field Calculator?

Im trying to calculate certain values of a newly calculated point. So I use the field calculator to write an equation to determine the values. Is there a way to save that equation, so that if and ...
9
votes
3answers
8k views

Replacing non-English characters in attribute tables using ArcPy and Python?

I have a few shapefiles where some of the attributes contain the non-English characters ÅÄÖ. Since some queries doesn't work with these characters (specifically ChangeDetector), I tried to change them ...
9
votes
1answer
372 views

Conditions in modeler field calculator

I want to check a vector file if there is a column "Source". If yes, nothing to do. If there is no column "Source" it should be created and filled up with '0'. Is this possible to do via the ...
9
votes
2answers
7k views

Calculating Date Field with today's date from datetime.date.today()?

I'm working on part of tool that will use arcpy.CalculateField_management to add the current date to the attribut table. I've wandered far and wide on the interwebs and can't seem to find the ...
9
votes
1answer
184 views

Documenting custom Python functions in QGIS

How can I document my custom Python functions in QGIS? I would like to offer users help for functions I wrote for them: I've tried adding a docstring: But whenever I click Load an error message is ...
9
votes
2answers
544 views

QGIS calculate radius of an arc to attributes

I have QGIS 2.18.16 installed. My problem is, how to calculate radius of an arc / curve feature (line)? The lines are originated from .dgn file, which I read with FME and wrote to PostGis DB. I have ...
9
votes
0answers
309 views

Calculating new field works inside QGIS Python console but not in standalone program [closed]

My code in the standalone program import sys sys.path.append("C:/OSGeo4W64/apps/qgis-ltr/python/plugins") from qgis.core import * from PyQt4.QtCore import * from PyQt4.QtGui import * import ...
8
votes
2answers
6k views

Troubleshooting ERROR 000989 Python syntax error from ArcGIS Field Calculator?

I'm trying to used the Python syntax in ArcGIS 10's field calculator and am thoroughly confused. So far the most basic calculations are failing me, and I don't understand why. I'm trying to create a ...
8
votes
2answers
980 views

Changing default parser in ArcGIS Field Calculator to Python?

Is there a way to change the default parser in the Field Calculator to Python? So annoying to always change now that I'm trying to move away from using VBScript... I'm using ArcGIS 10.1 for ...
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 ...
8
votes
3answers
18k views

Auto-incrementing field in feature class using ArcGIS Desktop?

So I'm relatively new to ArcGIS and ArcCatalog. I have created a field name of PROJECTID in a feature class in a Personal Geodatabase. The data type is TEXT. This will be a ten digit ID. The first ...
8
votes
2answers
19k views

Sorting feature class to calculate sequential ID field using ArcGIS Field Calculator?

I am in ArcMap and I want to sort the records based on a field and then do a Calculate Field with an auto-incrementing value with the sort in-place. Any ideas? It looks like I could get an update ...
8
votes
2answers
4k views

How to add a sequence to the attribute table?

Is there a way to use the field calculator in QGIS to create a range of values in a count sequence with a specified input range? For example, if I wanted to have the values 1 to 5 repeated within my ...
8
votes
5answers
1k views

Print out the properties of the attribute table in qgis?

I have to merge a lot of shapefiles into one great shapefile. So I want to compare the properties of the attribute tables to see if there are differences between the tableproperties of each shape (...
8
votes
2answers
3k views

How to convert a string field to a date field

I have a layer with points which represent the fatal road accidents and the field "dates_14_D" contains their date but its type is string. I would like to convert this string field to date field but ...