Questions tagged [field-calculator]

allows you to perform calculations on the basis of existing attribute values or defined functions in QGIS, ArcGIS, etc.

Filter by
Sorted by
Tagged with
108 votes
8 answers
265k views

Calculating polygon areas in shapefile using QGIS

How do I calculate areas of an area shapefile in square meters (m²) or in acres (ha)? I didn't find that functionality in the Vector Tools.
user avatar
  • 2,161
44 votes
4 answers
47k 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, ...
user avatar
  • 2,190
35 votes
3 answers
21k views

Refering to another layer with Field Calculator in QGIS

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, ...
user avatar
  • 1,876
32 votes
9 answers
69k views

Calculating latitude and longitude of points using QGIS

How do I easily calculate the lat/long of points using the QGIS Field Calculator? I saw a previous related question (Using QGIS API and Python, to return latitude and longitude of point?), but it ...
user avatar
  • 15.9k
23 votes
3 answers
59k views

Creating conditional statement in QGIS Field Calculator

In QGIS 2.8 I have a large data set and I would like to search one field for any values over a certain amount (in this case 20) and if the value is larger than 20, I would like to return a value of 1 ...
user avatar
  • 349
19 votes
3 answers
105k 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 ...
user avatar
  • 613
19 votes
3 answers
7k views

Assigning row number for sorted table by column in QGIS

In QGIS 3 the Field calculator has a great function called @row_number (in QGIS 2 it was $rownum) which returns (assigns) the number of the current row. Is there a way to make it work together with ...
user avatar
  • 9,226
19 votes
5 answers
34k views

Concatenating fields in field calculator of QGIS?

Is there a way to concatenate fields in field calculator of QGIS? (e.g. hectares + ' ha')
user avatar
  • 5,298
18 votes
5 answers
34k views

Using replace string function in QGIS 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'...
user avatar
  • 181
18 votes
3 answers
36k views

Replacing all null values from attribute table with zeros in QGIS

In QGIS 1.8 I have a new column in my attribute table with a lot of NULL values and I want to replace all them to zeros. How can I do that in field calculator?
user avatar
  • 183
18 votes
3 answers
35k 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. ...
user avatar
  • 743
17 votes
3 answers
21k 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 ...
user avatar
  • 171
17 votes
1 answer
27k 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 ...
user avatar
  • 4,892
16 votes
7 answers
11k 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 ...
user avatar
  • 1,990
16 votes
1 answer
31k 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'...
user avatar
  • 9,213
14 votes
4 answers
8k 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 ...
user avatar
  • 1,095
14 votes
8 answers
57k 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 ...
user avatar
  • 34.6k
14 votes
4 answers
10k views

Converting string field into date field in QGIS

In QGIS 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 ...
user avatar
14 votes
4 answers
2k 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 ...
user avatar
  • 201
13 votes
3 answers
2k views

Filling a field with a random string from a list in QGIS

I need to fill a field with false string data from a given list randomly. There are rand and randf functions generating random numbers. There is a similar (not identical) question: Updating attribute ...
user avatar
13 votes
3 answers
11k 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. ...
user avatar
  • 4,144
13 votes
3 answers
14k 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 ...
user avatar
  • 29.2k
13 votes
1 answer
17k 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 ...
user avatar
  • 2,285
12 votes
2 answers
19k views

How to copy same values to another field in attribute table in QGIS using field calculator?

I am trying to copy values from Parsel_ID to Parsel_NO using an equation (look at pictures) in field calculator but it is not working. What is the problem and how can I success this task?
user avatar
  • 599
12 votes
3 answers
7k 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 ...
user avatar
  • 1,085
12 votes
1 answer
505 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 ...
user avatar
  • 121
12 votes
2 answers
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 ...
user avatar
  • 844
12 votes
1 answer
3k 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. ...
user avatar
  • 123
12 votes
2 answers
13k 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 ...
user avatar
  • 971
12 votes
2 answers
2k views

Referencing another layer in Field Calculator inside Graphical Modeler

I want to use the Field Calculator inside the Graphical Modeler to create a new column in an input vector layer (LAYER1) using data in another layer (LAYER2). LAYER2 is the output of another algorithm ...
user avatar
  • 121
11 votes
5 answers
24k 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 ...
user avatar
  • 335
11 votes
2 answers
3k 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?
user avatar
11 votes
7 answers
79k 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 ...
user avatar
  • 111
11 votes
2 answers
4k views

Counting number of features within another feature using aggregate function in the QGIS Field calculator

My data: 1 polygon layer + 1 point layer My target: Calculate the number of points and the sum of a field within each polygon using the aggregate function in the QGIS field calculator. I know I can ...
user avatar
  • 481
11 votes
2 answers
9k views

How to use the Intersects function in the Field Calculator of QGIS?

I would like to have an example on how to use the Intersects function in the Field Calculator of QGIS. Basically, I want to know which feature from a polylines layer intersects a polygons layer and ...
user avatar
11 votes
1 answer
8k views

How to use QGIS field calculator in python?

I would like to use QGIS Field Calculator in Python to update the existing column based on certain conditions? How can I do this?
user avatar
  • 599
10 votes
4 answers
4k 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 ...
user avatar
  • 103
10 votes
2 answers
4k 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 ...
user avatar
  • 21.6k
10 votes
1 answer
5k views

Removing string to the right of a character using QGIS Field Calculator?

I have a string field and I want to delete the part of the string after a specific character in this case a '/'. I am looking for a way to do this using the field calculator in QGIS. I know I can ...
user avatar
10 votes
4 answers
3k 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 ...
user avatar
  • 203
10 votes
3 answers
10k 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 ...
user avatar
  • 4,892
10 votes
1 answer
8k views

How to copy values from field to another using arcpy?

Can some one please let me know how I can do simple field calculation like Copying From "A" to "B" in ArcPy? I have found lots os example on web which they all used extra expression and they were ...
user avatar
  • 1,434
10 votes
1 answer
21k 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 ...
user avatar
  • 103
10 votes
2 answers
9k 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 ...
user avatar
10 votes
1 answer
459 views

Determine roundness of polygon in QGIS

Suppose a polygon layer in QGIS with differently shaped polygons (no multi-geometries, let's keep it simple). Is there a way to calculate some kind of roundness characteristic of the individual ...
user avatar
  • 463
10 votes
1 answer
792 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 ...
user avatar
  • 103
10 votes
2 answers
1k 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 ...
user avatar
  • 72.3k
10 votes
1 answer
1k 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 ...
user avatar
9 votes
4 answers
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 ...
user avatar
  • 449
9 votes
6 answers
13k views

Creating label formatted like " 1,000' " from 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 ...
user avatar
  • 1,705

1
2 3 4 5
45