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
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
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
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
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
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
9 votes
2 answers
20k 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 ...
user avatar
  • 3,390
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
8 votes
3 answers
23k 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 ...
user avatar
  • 307
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
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
1 vote
2 answers
461 views

Using ArcGIS Field Calculator to create classes in new field?

I first classified firstCol into groups and then I want to give the groups with different weighted values in another field, SecondCol. I will need to give different weighted values very often. I find ...
user avatar
  • 141
7 votes
1 answer
15k 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 ...
user avatar
  • 1,095
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
5 votes
1 answer
40k views

Writing conditional (if/then) statements into ArcGIS Field Calculator using Python Parser?

I have gotten stuck on seemingly simple ArcGIS field calculator python expression. I obtained a great answer to a another similar question a few years ago: Using Range in Python expression of ArcGIS ...
user avatar
  • 1,977
5 votes
2 answers
498 views

QGIS: Use of a model output in the same model as a layer in the field calculator formula

I am trying to use field caluclator within a model. In this formula I want to reference the output (temporary layer) of another step of the same model (output objektfilter_strassen_wege, which is ...
user avatar
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
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
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
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
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
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
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
8 votes
2 answers
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 ...
user avatar
  • 15.9k
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
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
9 votes
1 answer
20k views

Summarizing column in QGIS field calculator?

I have data with a column containing a number value, and I want to divide the value of each feature by the total sum of all the values in the column (to get a percentage). So I would like to know if ...
user avatar
  • 2,486
4 votes
3 answers
9k views

Area is calculating wrong using $area in field calculator (QGIS 2.8.1-Wien)

There is a similar question posted, but the solution to it seems to be that polygons were multipart: Wrong $area from field calculator (QGIS) In my case, all polygons are singlepart. I have several ...
user avatar
  • 130
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
7 votes
1 answer
234 views

Incrementing value based on grouped field using QGIS field calculator

I've got a dataset of buildings roof segments in shapefiles. I need to sequentially number the roof segments from 1 to n of each building. Is there a way to do it with the QGIS field calculator? ...
user avatar
  • 562
2 votes
2 answers
3k views

Using File Geodatabase with Null values in Field Calculator of ArcGIS Desktop 10.0?

I want to use the field calculator to get the sum of a couple of columns. The problem is that some of them has Null Values. I am not able to find a solution. I tried this Python functions: stack( !...
user avatar
7 votes
4 answers
10k views

Calculating X and Y of line start and line end using ArcPy?

I have a series of polyline shapefiles and I am trying to automate the process of calculating the X and Y coordinates of the line start and line end using Python. I have added the 4 fields (startx, ...
user avatar
  • 819
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
5 votes
2 answers
758 views

Script (ArcPy) vs field calculator (Python Parser) behaviour of getPart in ArcGIS for Desktop?

From time to time I have to access geometry field and shuffle through points in it. Process is simple: Get shape Get it's part Iterate through part's points This is how it looks like in a script ...
user avatar
  • 21.6k
4 votes
2 answers
12k views

Using conditional statements in ArcGIS Field Calculator?

I have two fields, "P_Area" and "PC_Area", whose sizes I'd like to compare in a third field, "Areas_Equal". The "Areas_Equal" field should contain a "Yes" if the other two are equal and a "No" if they ...
user avatar
  • 337
3 votes
2 answers
1k views

Creating dummy variables between layers based on their geometries in QGIS [closed]

I have the following data: administrative boundaries for the United States: https://biogeo.ucdavis.edu/data/gadm3.6/shp/gadm36_USA_shp.zip vector layer containing coastlineshttps://www....
user avatar
  • 197
8 votes
3 answers
928 views

Adding consecutive unique ID starting from 1 for each distinct set of values

I need to add a unique ID (using $ID or @row_number) but the problem is that I need to start from 1 to "...n" considering identical values from other field, then, when there is a different ...
user avatar
7 votes
1 answer
13k views

Setting value of field in all selected rows of table using ArcGIS Desktop?

I have an attribute table in ArcGIS 10 (it's large - around 300,000 elements). I've selected some rows of the table using 'Select by attributes' and I want to set the value of a field for all of those ...
user avatar
  • 3,866
4 votes
1 answer
9k views

How to Calculate Field in joined table using ArcPy?

I have to calculate a field based on another field in a joined table, but an error occurs: "Parameters are not valid. ERROR 000728: Field !Table_A.field_A! does not exist within table" My code: ...
user avatar
  • 103
0 votes
3 answers
6k views

Extracting numbers from string field using Python Parser of ArcMap Field Calculator?

I am trying to calculate field test2 with only the numeric values from a string field test. The entire script is like: def makestr(test) list=[] for s in test: if s.isdigit(): ...
user avatar
9 votes
2 answers
17k views

Performing find and replace in QGIS field calculator?

I'm trying to replace selected string values in an attribute table, eg. "Text1" for "Text2" (QGIS 1.8.0), patriculary for those rows with NULL values. I have been trying to use the replace expression (...
user avatar
  • 451
6 votes
1 answer
4k views

Using Range in Python expression of ArcGIS Field Calculator?

what is the python expression for defining a range of numbers? I have tried numerous combinations but cannot get a simple range of angles (100 -200) to compute correctly. Screen shot :
user avatar
  • 1,977
5 votes
3 answers
18k views

Calculating incidence angle of polyline using ArcMap

How can I calculate the angle of each polyline in ArcMap?
user avatar
2 votes
3 answers
8k views

Python script for identifying duplicate records (follow up)

I am trying to calculate a field that marks duplicates and sequentially numbers them. I am using the code below that I found here: Generating sequential numbering for duplicate values in a field ...
user avatar
1 vote
3 answers
6k views

Replacing NULL values in geodatabase table?

How do you update NULL values within a geodatabase table using the ArcGIS Field Calculator (service pack 4) without changing other values to NULL? I've tried the suggestions on this previous question:...
user avatar
  • 34.6k
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
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
7 votes
2 answers
11k views

Calculating the average / MEAN of an attribute field in a QGIS model

I need to know how to calculate the average / mean of an attribute field in my point shape file. Is this possible to do with the field calculator? I just found the options min or max but not mean. The ...
user avatar
  • 2,285
6 votes
1 answer
4k views

What expressions for QGIS field-calculator?

I do not understand what language I have to use in field-calculator and labels on QGIS: SQL or Python? And where I can find the possible script/expressions to use? in the image you can see the ...
user avatar
  • 1,299
6 votes
1 answer
6k views

Calculating Percentiles in ArcMap?

I have a large polygon dataset (26,000) records with numerous attributes columns. I wish to calculate the percentile rank of each attribute. Say I have population_density in an attribute, is there a ...
user avatar
  • 459
6 votes
6 answers
2k views

Using ArcMap Field Calculator to set Row 1 (Column D)= Row2 (Column B)?

This is probably a fairly basic question but I have a long list of latitude and longitude values that represent telemetry points that will be the start point of the line. Before I convert them to ...
user avatar
  • 139

1
2 3 4 5
8