Field calculators (available in QGIS, ArcGIS Desktop, etc) can recalculate the values of a single field on all, or selected, records within a table using an expression.

learn more… | top users | synonyms (1)

28
votes
3answers
55k views

How to calculate polygon areas in QGIS?

Hi I would like to simply calculate areas of a area-shape file in square meters or in acres (ha). I didn't find that functionality in the vector tools. Could anyone here help me with that?
15
votes
6answers
6k 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 ...
11
votes
1answer
195 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 ...
10
votes
3answers
336 views

Field calculator: Calculate sum of parts of column, based on another column

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 ...
10
votes
3answers
8k views

How to round a column in attribute table (ArcMap)

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. ...
10
votes
4answers
357 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
8answers
14k views

How to Remove 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 ...
10
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
1answer
12k 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 ...
9
votes
5answers
6k views

Is there a way to concatenate fields in field calculator of QGIS?

Is there a way to concatenate fields in field calculator of QGIS? (e.g. hectares + ' ha')
9
votes
1answer
5k views

How to fill my column with consecutive numbers

I'm very new to QGIS, so forgive this simple question. Searching in older topics didn't help either. So: I make a new column in my attribute table and it has a default value (for example 0). I want ...
9
votes
2answers
804 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, ...
9
votes
7answers
41k 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 ...
9
votes
2answers
6k 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 ...
9
votes
1answer
6k 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 ...
9
votes
2answers
1k views

How to get latitude /longitude in Degree Minute Second (DMS) using QGIS field calculator?

I have come up with the following expression to convert 5.1234 to 5° 7`24.24" toint ($x) || '° ' || toint((($x) - toint ($x)) * 60) ||'`' || substr( (tostring(((($x) - toint ($x)) * 60) - toint(...
8
votes
3answers
41k 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 ...
8
votes
1answer
10k 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 ...
8
votes
5answers
526 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
2k 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 ...
8
votes
3answers
1k views

python script error- with GetParameterAsText [duplicate]

I have a seemingly simple code which iterates through a list of feature classes and calculates an ID field in the attribute table that is equal to the first 5 characters of feature class name. The ...
8
votes
1answer
223 views

Can you use wildcards for column headers in 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 ...
7
votes
4answers
4k views

How to remove 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 ...
7
votes
2answers
5k 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 ...
7
votes
2answers
2k views

Fnding wildcard string using Field Calculator script code?

I'm trying to find part of a text string in the CLASS_NAME field and return a text string to the Abrv_Name field using the Field Calculator in ArcGIS 10 via a Python parser. Here is what I have tried ...
7
votes
2answers
637 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 ...
7
votes
2answers
3k views

How to calculate perimeter of polygons in Quantum GIS?

Is there a way to calculate perimeter of polygons with the field calculator of qgis, like there is for area calculation?
7
votes
1answer
3k views

Meaning of exclamation mark in Python parser of ArcGIS Field Calculator?

In the following line, I don't understand what those exclamation marks mean? And why put everything in quotation? I don't understand the purpose of the variable expression, please explain to me as I'm ...
7
votes
1answer
10k views

Adding automated values to attribute field?

I have parcel and buildings layers. In their attribute tables I want to replace "NULL" values with numbers from 1 to 2000, in "Parcel ID", or "Building ID" field. How can I do this in ArcGIS ...
7
votes
3answers
232 views

Remove multiple characters from string field using field calculator (python parser)?

Is it possible to remove more than 1 character from a string in a field using the field calculator? I know !file!.replace(" ","") removes spaces in a string, but is it possible to remove spaces ...
7
votes
1answer
7k views

How to measure areas of features in OpenLayers plugin background maps correctly?

I can't figure out how to make areal calculations (eg. in km2). I have tried the 'field calculator', I have tried the 'measure area' function on the "attributes" toolbar, and i have tried fTools in ...
7
votes
3answers
4k views

Calculating Field based on name of shapefile

I have multiple shapefiles to which I have added a field called "gname1". For each shapefile, I want "gname1" to be set to the name of that particular shapefile, for every feature within the shapefile....
7
votes
1answer
2k views

Get shape filename in attribute field using field calculator

I apologize for crossposting against the ESRI geoprocessing forum, but it seems like this one gets answers. I'd like to have a modified append tool (ArcToolbox) that takes multiple shapefiles with ...
7
votes
1answer
1k views

Editing tables using SQL in ArcMap [duplicate]

We've recently started working with ArcMap, having used MapInfo previously. I've created a shapefile in ArcCatalog and want to update some columns using SQL. In MapInfo I'd write the following command ...
7
votes
3answers
4k views

How to replace non-English characters in attribute tables using 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 ...
7
votes
1answer
156 views

Filling fields with conditional clauses

I have four fields in my shapefile. I would like to fill only one of them (cell of attribute table) and automatically after to write one cell the others one will be filled by conditional clause. I ...
6
votes
3answers
5k views

Doing If/Then over multiple data columns in Python Parser of ArcGIS Field Calculator?

I have some VB code saved that looks at two columns of data, and populates a third with the low value. Pre-logic Script Code: Dim output as double if [MIN_LEFT] < [MIN_RIGHT] Then output = [...
6
votes
3answers
2k views

calculating a field in which null values may be present

I would like to calculate a field (short integer) using other fields (short integer) present in the table. In some cases these fields may have null values for one or more of the fields. For example, ...
6
votes
1answer
207 views

How to remove comma from combined fields which should be null?

I have Drivers License as one field and State as the other and there are to be combined and formatted as Drivers License, State. How do I handle records that do not have either a Drivers License or ...
6
votes
2answers
140 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 ...
6
votes
5answers
13k views

How do you test for a NULL string field in the Field Calculator with Python?

I am trying to perform an operation on a string field with a condition that it contains data. Referencing None with Python does not appear to work when the field is nullable and contains <Null> ...
6
votes
2answers
604 views

How to delete last part of a string starting from the 1st non numeric character? [closed]

I'm looking for a Python or VB statement to remove the last part of a string, starting where the 1st non Numeric character appears, using the Field Calculator in ArcMap 10. Here's an example of what I'...
6
votes
5answers
2k 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 ...
6
votes
3answers
6k views

Field Calculator syntax?

I can't get the syntax correct for a fairly simple if statement. Right now it looks like this: dim Output as Integer If [HECTARES] >= 30 AND [HEIGHT] >= 17 AND [CROWN] >= 59 THEN Output = ...
6
votes
2answers
5k 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. ...
6
votes
1answer
195 views

How to make a automatic updated date and time field in QGIS 2.14?

I want to make a date and time upadated 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 shapfile and ...
6
votes
3answers
1k views

Random value calculation in QGIS

Is there a way to do a random value calculation within a range in QGIS? I have been able to do this within ArcMap Field Calculator with the following code: Dim max, min max=20 min=5 x=(Int((max-min+...
6
votes
1answer
406 views

How to classify time periods in a new field, using Python?

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
2k views

Summing Attributes from a Related Table?

I have a line feature class representing road segments, with each road segment having a unique ID. This feature class has an attribute of average observed daily traffic counts. I have another table ...
6
votes
1answer
3k views

ArcMap Field Calculator syntax (again)

I'm trying to string together a field calculator script that will populate all the records of a field at once based upon values in a number of fields. I can't even get the first part of the command ...