Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [field-calculator]

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

1
vote
0answers
80 views

Field Calculator not Allowing Decimal Numbers (QGIS 3.6) [closed]

QGIS version 3.6 When creating new virtual fields in shapefiles, the field calculator does not allow the output field length or precision to be changed. These are both greyed out except for when ...
1
vote
2answers
158 views

Getting QGIS processing script field calculator error?

I have a processing script that I created for QGIS 3.4.5 but I keep getting the following error: Traceback (most recent call last): File "", line 66, in processAlgorithm File "C:/PROGRA~1/QGIS3~...
1
vote
1answer
44 views

Autoincrementing one character in calculate field of ArcGIS Pro?

I am using ArcGIS Pro. I have this set of points where I like an unique id (uid). The only thing they need to be unique is a counter of some sort at the end. I have another field with some id that ...
2
votes
1answer
20 views

Modify script so only empty fields are changed in ArcGIS Pro?

I currently use a script that converts the integer in OBJECTID to a string and combines it with another string (in this case UAW,) to populate a field Field = str(!OBJECTID!) + "UAW" Now that I have ...
0
votes
0answers
108 views

Converting Text Field to Numeric in ArcGIS Pro?

I'm trying to convert text to numeric, but am unable to in ArcGIS Pro. Is there a Python function? I tried int(!FieldName!) but I think NULL values are messing it up?
0
votes
2answers
63 views

Remove duplicate strings from a field with Field Calculator in ArcGIS

I tried using the same codeblock in this post: Remove duplicates from a field, but it is just copying the contents and not removing duplicates. I think my data is formatted the same. Anyone see what I'...
1
vote
1answer
27 views

Using Python Lists in Calculate Field Code Block? [closed]

I'm looking for some help in explaining what exactly is occurring with the following code: MaterialLife = "LifeMaterial(!"+Material+"!)" codeblock2 = """def LifeMaterial(mat): material = {"ABS":...
2
votes
2answers
162 views

Calculating multiple fields using ArcPy?

I have found a script that can add multiple fields to my existing shapefefile. Now, I need to add to my existing script so that it will calculate the new fields that have been added. In most cases, ...
0
votes
1answer
29 views

Combine Two Fields Into One

I joined two tables to a shapefile and the output table has a field from each. Both fields represent the same thing so I'd like to combine them into one. You can see a clip of my fields below, where ...
3
votes
1answer
55 views

Python time condition within Calculate Field

I am attempting to assign 0/1 values to each row with a point feature class based upon a time dependent condition with ArcMap Model Builder 10.2.2. The points are categorized based upon a series ID ...
2
votes
1answer
23 views

Splitting ID number along hyphens and creating new field with only parts of ID In Field Calculator?

I have a shapefile with polygons and each polygon has an ID number that follows a pattern like this: SMP_ID 1077-1-1 8-2-2 1281-1-3 304-2-1 In have created a new field and I need to populate it ...
3
votes
1answer
144 views

Use intersection in field calculator

I want to use the tool intersects in the field calculator. If the condition is true, I want to set a result field to a specific number. The field calculator doesn't accept my expression but I can not ...
1
vote
1answer
43 views

How to write Python if/then statement using information from two fields in field calculator

I am using ArcGIS Desktop 10.6.1. I create a new field of type short integer in the Attribute Table. My new field is named CIPOT and I want to populate it with values from the field CI, but only if ...
2
votes
2answers
147 views

Using Python in field calculator to extract highest value from 3 columns [closed]

I have three columns, one for percentage White, percentage Hispanic, and percentage African American per census tract. I'm trying to use Python to extract the population subtype with the highest ...
1
vote
1answer
55 views

QGIS working with a point and polygon layer

I have 2 layers, layer A ( point data) and layer B (polygon data). Within layer A I want a column which will indicate Yes or No if a polygon is within 500m. I have created a 500m buffer for layer b ...
0
votes
1answer
38 views

Using Calculate Field tool to make empty field be populated with adjacent field's data?

I have about 80 species of birds with at least about 100,000 records each. I used the iterator tool to create a field named [Count] for each species, but now need the empty field to be populated with ...
2
votes
2answers
38 views

Calculate field does not update using ArcPy

I want assign 33 if the field no_apt is zero and 34 if no_apt is any else value. The model run without any error, but no value are assigned the field GGV_kW. What is wrong with the code since it doesn'...
4
votes
1answer
80 views

How to re-use an expression, stored as a string, in QGIS Field Calculator

As discussed in this question, QGIS automatically saves recently used expressions in the field calculator. But recently used expressions are deleted after a while. Sometimes I need to re-use an ...
5
votes
1answer
170 views

How do I get this query to work in the field calcuator in QGIS 3.2?

I have a geopackage file which contains point data with column of 'depth of cover' and score. In the score column I am using the field calculation to create an expression so that any number less than ...
2
votes
1answer
66 views

Extract features in .gdb file based on their attributes

I have a .gdb file with >17,000 features. Simplified example of attributes table: ID NAME DATE ETC 0001 london 2012 12 0002 london 2012 23 0003 thame 2012 45 0004 ...
2
votes
1answer
65 views

Simplifying variable (if condition) with field calculator in QGIS

I want to simplify the variable ("SIOSE_CODE") which has values like this: A(90MTRfr_05PST_05SDN) A(65PST_35MTRfr) A(70FDCfr_10PST_10MTRfr_05MTR_05SDN) The first number (here 90 resp. 65, resp. 70) ...
3
votes
2answers
163 views

Extracting substring from field in ArcMap using Python Parser of Field Calculator?

I have some parcel data where I need to extract a subdivision name from a long string. The format is always "Subdivision: ____ ______ _____" etc. BUT, there is no uniformity to what comes before or ...
1
vote
1answer
151 views

Argument 1 has unexpected type 'set' Error using processing in QGIS?

I am currently working on a code that adds a field to a shapefile and inputs its filepath. I understand that the processing.run has changed from qgis 2 to qgis 3 but I am not sure why I am getting ...
3
votes
0answers
42 views

Time series condition through field calculator [closed]

I am attempting to filter some time stamped data which I have enabled through the Convert Time Field tool, depending on a true/false condition. I am doing this through the field calculator within ...
1
vote
1answer
37 views

Use relation to apply same colour to children feature

I'm looking for a function with field calculator in a symbology context to apply the colour of parents features to the children with transparency.
0
votes
3answers
61 views

Converting VB codeblock to Python in ArcGIS Field Calculator?

I have created a tool in Model Builder to plot telecoms data - the user clicks a point on the map, enters a radius and enters an azimuth. The model then creates the buffer and cuts a segment out of ...
1
vote
0answers
46 views

Using IF-Statements in Calculate Field Code Block inside an Iteration

I have created a model in ArcGIS 10.2 that iterates through some feature classes in order to add a field 'Zmin10' (double) and calculate the field value based on a variable (called "Minimum") to which ...
1
vote
0answers
65 views

Making sequential number's not based on Object ID number

I have a question about sequential numbering. I found a script (i'll put it below), which allows me to make a sequential numbering based on OID and thats good. But what i need is different structure ...
0
votes
1answer
41 views

VBA/Python If/then statements in Field Calculator for one column based on another not working

I know this question has been asked a hundred times on here, for example: Basic If/Then in Python Parser of ArcGIS Field Calculator? Using if/elif/else statements in ArcGIS Field Calculator? Checking ...
0
votes
0answers
40 views

Calculating sequential numbers into sorted table not dependent on OBJECTID? [duplicate]

I am having a problem with adding sequential numbers to the new column based on other sorted value. I would like to use 'Sort by' column to be able to generate numbers in the 'Required number'column. ...
0
votes
1answer
95 views

Extracting numbers from string field but omit some unnecessary cells using Python Parser of ArcMap Field Calculator?

I refer to Extracting numbers from string field using Python Parser of ArcMap Field Calculator? The script above works fine for me, but I have to develop it a little. What I want is just to omit ...
0
votes
2answers
42 views

ArcGIS If/Else with calculation

I am seeking to calculate the variable MASSSTAB through rounding the variable LAENGE and doing some basic math. My codeblock currently looks like this: x = long(round(!LAENGE!, -1)) def ifBlock(m, ...
3
votes
2answers
67 views

Refering to (Joined) Field Names in arcpy in Field Calculator

I'm trying to update the locations of a point FeatureClass using a table. I have joined the table to the featureclass, and am attempting to use Field Calculator to update the SHAPE field. I found ...
1
vote
1answer
42 views

Line first,last node distance along another line QGIS

I am using QGIS 2.18.6 . I have created two line layers. First layer "testroad" with long line (road). Second with short lines along,near road. I would like to know distance of first and last point of ...
3
votes
1answer
138 views

Referring to Null value with ArcPy Expressions?

How do I refer to Null values in a field using an expression in Python? I've tried using the following as well as = None and =Null but nothing has worked yet: ScoreCondition = "Cond_Score(!"+...
5
votes
2answers
124 views

Measuring average, min and max of vertex height of linear shape using QGIS?

I have a linear shape, all of the vertexes of each segment has a z-value, stored in the geometry. I need for every record, segment the average, min and max height value aggregated from their vertex ...
0
votes
1answer
67 views

Simple Field Calculation With No Results in ArcGIS Pro?

I have a grid in ArcGIS Pro that I've named the X and Y axis (in separate columns) and am now trying to do a field calculation on the total grid name (I've tried using both single and double quotes. I'...
2
votes
4answers
80 views

More Efficient Conditional Statements - ArcGIS Field Calculator

I am new to Python and have successfully created the following statement that writes a change period value (01 or 02) based on the municipality and date fields. I am wondering if anyone could point ...
1
vote
1answer
40 views

How to turn a string field with 2 numbers in two numerical fields in the atribute table?

I have a feature class with a big number of features. In the attribute table I have a string field made from two numbers separated by an underline (e.g.: 0_1, 98_237, 31_31...). I want to create two ...
2
votes
2answers
137 views

Converting none to zero (0) in geodatabase table using ArcPy?

I have an attribute table looks like this How do I convert Nulls into 0? I've tried to set this table non nullable type but got this: while the official doc says this: At least one of them is ...
0
votes
2answers
72 views

Concatenate fields (double and string) to create address using arcpy

fields: STNUM = double STRDIR = string STRNAME = string STRTYPE = string Tuple and s.format I have tried: arcpy.CalculateField_management (newparcelsUTM, "SiteAddress","{0} {1} {2} {3} ".format('!...
0
votes
1answer
127 views

Why the strange area calculation in QGIS?

I have a 550 meter by 550 meter square polygon in a shapefile. The QGIS 2.18 project and the shapefile both reference EPGS:32648 WGS84/UTM48N. EPGS:32648 uses meters as the units. When I use $area ...
4
votes
3answers
241 views

Converting full road names to abbreviation using ArcGIS field calculator?

I have a data table with a column 'names' that have street names with street type (Road, Lane, Street etc.). I need to get the names in a format like in column 'new_names'using field calculator in ...
2
votes
1answer
107 views

Different results using $length (field calculator) in QGIS versions 2.18 and 3.0

I use the field calculator to measure the length of LineStrings in my shapefile layer, but i get different results when using QGIS 2.18 or QGIS 3.0. If I am using the local coordinate system the ...
0
votes
1answer
58 views

Splitting second word of attribute using Python Parser of ArcMap Field Calculator?

This is Field Calculator in ArcMap. I am trying to split the word after the first space if the words starts with "San" like San Francsico, San Diego and etc. It return an error. Below is the script.
2
votes
1answer
40 views

Number each value in each section due to other value

I'm working with map of plants in garden. This garden is divided into about 40 sections. Plants of one species have their number for example every Scots pine is 12 and every Common oak is 15 in field "...
0
votes
2answers
260 views

Using Arcade, AGOL, and Attribute Expressions to Create a Text field with Quotes

I am working on creating a Attribute Expression that would display HTML with quotes in the field. I tried putting double quotes for the inner quotes, but I keep getting "Parse Error: Unexpected String"...
4
votes
1answer
259 views

Using QGIS field calculator with geometry operations between layers

A curiosity question. I am looking for making a field calculation with QGIS, I see is possible to include the geometry field of the same feature layer, nevertheless I was wondering if it is possible ...
2
votes
1answer
59 views

ArcGIS Pro Field Calculator completing without error, but no change to Feature?

I'm attempting a research project in which I am seeking to categorize a municipality's Property Use Codes as Generalized Land Uses. For example, "AGRII - Developed Farmland" and "INDGR - Grain ...
0
votes
2answers
289 views

How to convert Zipcode+4 into standard 5 digit zip code using Field Calculator

I have a ZCTA shapefile that I would like to join to a table by the zipcode. My problem is that some of the zip codes in the table have a 5+4 digit format, and the ZCTA shapefile has only the 5 digit ...