# Tagged Questions

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.

292 views

### python add fields that may have NULL values

I would like to use python 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. ...
227 views

### Arcpy Calculate Field Formatting Syntax

I am trying to field calculate a double field (PID) to a new string field (PIN). Using: qry = '"139-{}".format(!PID!)' arcpy.CalculateField_management(out, "PIN", qry, "PYTHON") Given a PID = ...
144 views

### Populate an attribute table field using the 'startswith function

I am hoping that someone may be able to help me. I am new to ArcGIS, and even newer to Python. Working in ArcGIS 10.1, I have done is created a new text field in an attribute table, which I have ...
1k views

### Calculating a field based on two other fields, if they exist [duplicate]

I'm using ModelBuilder to iterate through ~800 shapefiles to add and calculate a new field (I'll call it Field_A). Field_A needs to be populated by either Field_B or Field_C, whichever exists. Half of ...
3k 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 ...
933 views

### Generating sequential numbering for duplicate values in a field sorted by ObjectID

I am trying to figure out a solution to an field calculation problem. What I'm trying to do is automatically (using either ArcPy or the Field Calculator) generate sequential numbers, beginning at 1, ...
4k views

### Using Value from Iterate Feature Selection to Calculate Field in ArcMap 10.1 ModelBuilder

I have two polygon feature classes, an alignment layer and a parcels layer. I am trying to use ModelBuilder to create a tool that will do the follow: iterate through groups in a single field of a ...
428 views

### Need a Python field calculation that works like the DatePart( ) VB Function

I have a field called Abandoned Year (short integer data type) that I am trying to populate with a four digit year from a column called Decommission Date (Date data type). I have done this in the ...
135 views

### using “abs()” function in QGIS field calculator?

I'm pretty new to GIS in general and I'm trying to take an absolute value of the difference between two fields in field calculator when creating a new field, but using ABS () returns an invalid ...
251 views

### Syntax for ArcGIS ICalculator object?

I have a code snippet that I can't figure out: 'Define a calculator for NewArea field pCalculator = New Calculator With pCalculator .Cursor = pCursor .PreExpression = "Dim ...
871 views

### Field calculator script not working

I am trying to do the following in the field calculator in ArcGIS 10 if [IncdStDir] = " " then [IncdStNo] &" " & [IncdStName] &" " & [IncdStSfx] else [IncdStNo] &" " & ...
2k views

### Recoding values based on contents using ArcGIS Field Calculator or Python?

Is there a convenient (or even effective) method for recoding field values using the field calculator or standalone python script? In this case, I am given several unique strings to identify a type ...
56 views

### Stacking multiple selected points in ArcGIS

I would like to find a way to stack multiple selected points in ArcGIS, either using the field calculator or python script. For example, I want to snap all points representing houses on a street into ...
44 views

I'm currently working on a dataset with 3.8m records. I have a very simple expression to update a field that I want to execute using the Field Calculator, while having the Attribute Table open. Do I ...
60 views

### Sequential attribute field calculations with null values using Arcpy

I have a series of x,y co-ordinates converted from a .ply file. I was able to extract the file into a suitable x,y format for arcmap, the issue I have is that they are co-ordinate points representing ...
70 views

### Reproducing GRASS GIS network analysis tutorial in QGIS Field Calculator

Im looking to reproduce the assigning of road speeds as denoted in a GRASS GIS tutorial (v.net.alloc tutorial), where the road speed is assigned by road type (i.e. 'interstate' = 75 mph etc.) to then ...
52 views

### Calculate field using data from excel table

I need to interpolate data that I have in a excel file using data from an attribute table of a point feature. I want to create a new field on the attribute table with the result of that interpolation. ...
105 views

### Calculating percentage using QGIS Field Calculator?

I have a shapefile containing counties and their respective population for a given area. I woould like to use the Field Calculator to create a new field that contained the % of the total population in ...
217 views

### Controlling label/attributes of grid/fishnet index using ArcGIS for Desktop and ArcPy?

I have used the Grid index feature tool to create an index grid. The label/attribution of the page names are populated in a "row" orientated manner. eg lef to right a1,a2,a3,a4,a5,a6 b1,b2,b3,b4,b5,b6 ...
75 views

### How can I copy non-blank values to a new column from different columns in the same layer in QGIS?

My data: n1 n2 n3 NEW_COLUMN 11 null null null 33 null null null 55 My desired result: n1 n2 n3 NEW_COLUMN 11 null null 11 null 33 null 33 null null 55 ...
32 views

### Alphabetical Sort within a Record

I am performing a union on a polygon feature class with multiple overlapping polygons. Each of the records in the resulting feature class can be thought of as "unique area" polygons made up of the ...
105 views

### How to change GK-coordinates to UTM with the field calculator in QGIS?

i have a qgis project in ETRS89 (UTM) with some vectorshapes. i already transformes them from GK into UTM. but now the attribute table still show me the GK-coordinates. HOW can i change it? with the ...
2k views

### Converting values in datetime field to strings in text field using Python parser of ArcGIS for Desktop?

In the attribute table of my file geodatabase feature class I have a populated field called DateField of type date, and a text field called TextField. I have not yet hit on a way to convert the ...
158 views

### Add or subtract days to date field using the field calculator

I am using ArcGIS 10.1 I'm not a programmer I want to use the field calculator to add 4 days to the current date if the status is "delivery" or subtract 5 days if its status is "order" this ...
97 views

### ArcGIS Field Calculator passes European-formatted floats as tuples

I have the problem that the ArcGIS Field Calculator doesn't read a float number when it is included in Python by referring to the field that contains it, in this way: def giveResult(floatValue): if ...
195 views

### How to calculate area of shapefile with a merged layer

so i have 'save as''d the new project and layer with my new Custom CRS project string being '+proj=laea +lat_0=70 +lon_0=0 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'. ...
248 views

### Populate field with current time

I am trying to populate a field with the current time. Here is what I tried that did not work: Start editing Open Attribute Table Add Field -> Name: time Type: Date Right Click on Field Name ...
149 views

### Problem with Python codeblock recognizing a field

'<'First Post Alert> I've been through multiple iterations / gyrations, and while there may be multiple problems here (and I'll appreciate feedback on all of them), the recurring issue is that the ...
113 views

### Call field from zip() into Field Calculator expression ArcGIS

I've been trying to find a way to call in field names from a zip(). Basically I have 12 fields called "Flw_days1", "Flw_days2" etc and corresponding "Depth" fields that need to be calculated using the ...
79 views

### Expression to create and populate column based on filtered fields

I wanted to create a column and populate it with data based on data from other fields. If column_1 contains fields which has similar string (eg. field_1 = "Country: UK", field_2 = "Country: US", ...
1k views

### How to make autoIncrement number start with (001…009, 011…099)?

i have a challenge with my time in my work, i have feature class called "Parcel" storing many data, i generated an autoIncrement number by using field calculator, in field "parcel code" Expression: ...
437 views

### How to assign values to field using if/then logic involving multiple fields?

I want to run a field calculation on a string field named [territory] that first looks at a string field [majr_src] to see if there is a value other than "NONE", if so [territory] = [majr_src]. If ...
257 views

### Correctly calculating attribute table column in gvSIG

I am trying to conduct a multicriteria evaluation, and it is necessary to check the compatibility of two different land-use types that I have in seperate layers. I am working in gvSIG 1.12, and have a ...
560 views

### Why is field calculator returning NULL for \$x and \$y in line and polygon layers?

I am trying to include XY coordinates in the attribute tables of several of my vector files; they are line and polygon files. I have tried two methods; first I used \$x and \$y in the field calculator ...
201 views

### Using Sum() or something similar with CalculateField_management and FieldLists

I need some help with using variables with CalculateField_management tool. I've tried several different scenarios but don't seem to have any luck. What I have is a list of fields containing water ...
402 views

### Using update cursor on a field with a domain

I have been replacing field calculations with python update cursors in many of my work flows and today I ran into a problem. The fields being updated have an attribute domain. so now, when I ...
128 views

### How to convert QGIS Field Calculation to ArcGIS?

I have a field calculator expression I use in QGIS to generate unique IDs that are sequential, but start with a text string. I now need to perform the same thing in ArcGIS, but I am unsure of how to ...
2k views

### Incorrect field name resulted in RuntimeError: ERROR 999999 (Also, better code for adding and calculating fields)

This is the bottom half of my code (and it's been edited somewhat to share publicly). The code works perfectly fine when the fieldList has only three fields in it, but when I populate it with all 108 ...
364 views

### Mysterious Invalid Syntax in Field Calculation

I'm trying to calculate a field in Model Builder using the Calculate Field tool. I'm using the following code block and expression in the calculation, but am getting an "invalid syntax (, line 1)" ...
865 views

### Using Python in the Field Calculator, how do I refer to a field in another shapefile?

I want to compare the changes in geometry between two shapefiles (of election districts in NYC. One is from 2001 and the other 2005). I am attempting to calculate a new field in the 2005 shapefile ...
350 views

### Field calculation in ArcGIS Desktop?

i have a data which contain a code of area an value of area in shapefile, ex.: area|value 1|33 1|43 1|31 2|12 2|43 3|66 3|76 the question is how to calculate total value per area with arcgis, i ...
2k views

### QGIS field-calculator replace function

I've got a Shapefile containing contourlines which I would like to style differently according to their value. For that reason I created a field named "100s" where I would like to give values from ...
471 views

### How to implent a “maketrans” python function on field calculator

i'm traying to implent python string translate function at field calculatore http://www.tutorialspoint.com/python/string_translate.htm in order to fix hebrew imported from cad. here is the code - def ...
220 views

### Why isn't this Python calculation working correctly?

I want to label the source files for a unified shapefile, and there are three respective columns for each. If there is no value in the column, there is no data from that source; if there is a value in ...
67 views

### How to use QGIS advancedpythonfieldcalculator from the console?

I'm trying to use the field calculator in a script like so: processing.runalg('qgis:advancedpythonfieldcalculator', output_layer, 'Latitude',1,12,5,'','\$y',output_layer2) Not sure exactly how to ...
61 views

### Field Calculator - conditional function and string variable?

I know this question has been asked before in different fashions, but I can't seem to get my python script to work despite looking at all the relevant questions I could find. I am simply trying to ...
95 views

### Formatting SQL expression for calculate field (management) tool?

I am trying to take the population census tract and calculate the percentage of population by each census tract in the field (Populati_2). To do this I'm creating a new field with the total sum of the ...
138 views

### How to calculate Statistics of an attribute field to use it in another calculation

I want the statistics of an attribute field to use in another calculation, i can view the statistics using the field properties menu I want these to normalised the data of field 'Ia' using the ...