Questions tagged [field-calculator]

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

Filter by
Sorted by
Tagged with
3
votes
1answer
1k views

Using Python Parser in ArcGIS Field Calculator to compare two fields?

I'm trying to use field calculator to compare two fields in a table of tax parcel data, Land Value (LAND_VAL) and Improvement Value (IMPRVT_VAL). My goal is to determine (1) Parcels with land value ...
3
votes
0answers
6k views

Adding count of features in categories to legend using ArcGIS for Desktop? [duplicate]

I am using ArcGIS 10.1 for Desktop and I would like to know How to add the Count (which is visible on the Symbology tab of the Layer Properties dialog) to the legend?
3
votes
1answer
12k views

How to search text string and select item in QGIS?

I have a table attribute with complete roads name. I have to search items by digiting a part of the road name and I need to colour all the items selected. eg: ROAD NAME: / road 01 / road 02 / road 11 ...
3
votes
3answers
2k views

Concatenating strings from two fields using Python in ArcMap Field Calculator?

I'm new to Python scripting and I don't understand what is wrong with this code. I want to concatenate the string values from GRID1MIL and GRID100K. I've created a text column MGRS to begin with. I ...
3
votes
1answer
174 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(!"+...
3
votes
1answer
180 views

Weighted values of field in QGIS

In QGIS in the Attribute Table, I have a field with values. For this field, I need to calculate the Sum of all its values and divide by the number of values that are not equal to "NULL". Afterwards, ...
3
votes
1answer
409 views

Why do area measurements from “measure area” tool and field calculator differ?

My problem is when using the "measure Area" tool on the toolbar I get the correct value but when using the field calculator in the Layer Attributes the area is very different including -ve areas. ...
3
votes
1answer
1k views

How to calculate distances in QGIS field calculator?

So I'm using qgis 2.6.0 and I have a csv (converted into a .shp) with two geometry columns, I want to create a new column with the distance between the two geometry: shot.lat shot.lon haul.lat ...
3
votes
1answer
53 views

Getting Properties of Next Record Using Calculate Field Tool in ModelBuilder?

I'm trying to calculate the distance between the centroids of adjacent records (adjacent in the attribute table, not necessarily in space) into an attribute field. I'm planning on using the ...
3
votes
2answers
436 views

Using ArcGIS Desktop field calculator (python) to parse date

I'm trying to parse a datetime field using python (but have never used python for it before). I have a field that contains a valid date, but not a valid time... and other fields that have valid hour ...
3
votes
1answer
927 views

Why is this field calculator expression evaluated incorrectly when using Python syntax?

I have a polygon featureclass containing an integer field 'gridcode'. I've added 2 new float fields VB_calc and Python_calc, both of which should be equal to gridcode / 1,000,000. If I calculate the ...
3
votes
1answer
206 views

Do pad functions of QGIS Field Calculator have bug?

I have this expression in the field calculator: regexp_replace('1', '^(\\d+)', rpad('\\1', 3, '0') ) gives 01 rather than 001 as expected. the *pad functions work fine when called outside ...
3
votes
1answer
466 views

Using QGIS Field Calculator to replace backslash?

I actually use the Field Calculator "replace" formula that works very well but I have some '\' caracters in my field that I cannot replace. ex : '\naninana' and I want to keep only 'naninana'.
3
votes
1answer
2k views

calculate value using maximum value from different feature class

I'm trying to get the maximum numeric value from one feature class and use that value in an expression to calculate values of a different feature class. fc2.bldg_id = max(fc1.bldg_id)+1 Can this ...
2
votes
1answer
171 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 ...
2
votes
3answers
109 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 ...
2
votes
1answer
5k 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 ...
2
votes
2answers
2k views

Is the derived area/length/xy values of a polygon/polyline layer in QGIS usable?

I have a raster that is projected to a state plane CRS and I am adding polygon/polyline shapefiles that are projected to WGS84. On the fly transformation is set to reproject to my raster CRS. When I ...
2
votes
0answers
90 views

How to measure area of polygons generated from gps data in qgis? [duplicate]

Somebody classified my question as a duplicate. But applying the answer doesn't work for me. Here is what I did: - I made sure that my layer is in a projected coordinate system (UTM30N, WGS84) - I ...
2
votes
1answer
523 views

Use Python in ArcGIS Field Calculator to return value based on numeric value in any of three other fields

I am trying to calculate a new field in ArcGIS 10.5 Desktop using the field calculator, based on the value in any or all of three other fields in the same table. I have not used Python for a while, ...
2
votes
1answer
46 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 "...
2
votes
2answers
6k views

Using Python to field calculate Lat/Long with decimal degrees rather than meters

The below is a snippet of a python script that I am writing that basically adds two fields - Latitude and Longitude, then calculates them. I could use the Add XY Tool which gets me to the same point. ...
2
votes
2answers
1k views

Using Python Script tool in ModelBuilder to check if field exists, if not, create one?

I'm trying to create a script tool to use in ModelBuilder that will check the incoming dataset for the existence of a particular field. If the field exists it should simply go on to the next calculate ...
2
votes
2answers
3k views

Recoding values based on contents using ArcGIS Field Calculator?

Is there a convenient (or even effective) method for recoding field values using the field calculator? In this case, I am given several unique strings to identify a type of road feature. For the ...
2
votes
1answer
2k views

Counting occurrences across a record in ArcGIS 10.0

I'm a student at Millersville University, PA studying for a BA in Geography with a concentration in GIS. I've stumbled across this site for questions I've had over the past year or so with getting ...
2
votes
2answers
338 views

Performing Conditional Calculate Field with Many to One using ArcMap?

Anyone have experience calculating a field based on a many to one scenario? I have a feature class in a geodatabase with a field of unique names. Feature Class Table (let's call this "MAINTABLE") ...
2
votes
2answers
4k views

Debugging ERROR 000539 from CalculateField in ArcPy?

I previously successfully used the sample code here: How to calculate Field using part of filename in ModelBuilder? # Import standard library modules import arcpy, os, sys from arcpy import env # ...
2
votes
3answers
240 views

How to write FIDs of points within each polygon to polygon field?

I have two feature classes one with points one with polygons (in ArcGis 10.2). Now, I want to write into a String Field of the polygon layer a list of all the Point-FIDs that are within each polygon (...
2
votes
1answer
503 views

if/then with VBScript in ArcGIS Field Calculator giving Error 000539: SyntaxError: invalid syntax?

What is wrong with this VBscript in the field calculator? ColumnC= if [ColumnB] > 0 then [ColumnC] = [ColumnA] / [ColumnB] endif Each time I receive this syntax error message: Error ...
2
votes
1answer
890 views

Field Calculator operation is not working

I've done this 100s of times and I can't understand why it won't work! I'm trying to copy the first 8 digits of from a HUC 12 (Hydrologic Unit Code) to a new field, which represents a larger ...
2
votes
1answer
183 views

Decimal Degree data erases itself between edit sessions in QGIS

I have a shapefile with point data. I calculate the $x and $y of the points successfully I save the changes and close the edit session. Once I reopen the attribute table, the data after the decimal ...
2
votes
3answers
531 views

If else if in ArcMap Field Calculator (Python)

Help! I think I am missing something that must be so obvious but I cannot figure out what I am doing wrong. Here's some background: I have one short integer field (MajAspNum) that has values 1-10....
2
votes
1answer
541 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 ...
2
votes
1answer
63 views

An equivalent for field statistics for records

I know how to obtain various statistics for a field, or "column", in an attribute table in ArcGIS. Is there any way to obtain a Mode figure for records, or the "rows" in a table? For instance, an ...
1
vote
2answers
50 views

Use a python expression in Field Calculator to sum each row across several columns

this seems like it should be easy but I am new to python and am having trouble... I have four columns. I would like perform a field calculation that sums the values by row for three of the columns and ...
1
vote
2answers
136 views

How to work around Field Calculator's character limit?

I'm trying to use the field calculator in ArcMap, however my code is way too long (1337 lines) and there seems to be a character limit: I'm only allowed to paste the first 103 lines. Is there an ...
1
vote
1answer
81 views

Rearranging display of Date Field in ArcGIS Desktop?

Can you rearrange the text in date field type in ArcGIS? Eg. Map_Date - 05/30/2014 (I want to reformat this to 2014-05-30) I've been trying to use the field calculator on all my records, but cannot ...
1
vote
0answers
40 views

QGIS 3 - Set width of line by attribute

I have a line-layer and want to style the line by using a data-table with no geography - I am using GeoPackage. With other words, how can i get a field-value (i have two fields for filtering the ...
1
vote
1answer
32 views

Auto incrementing every second row in ArcGIS Desktop?

How do I auto increment every second row (field type is short and I work with 150 fields) in ArcGIS Desktop 10.3.1? I saw this code in https://support.esri.com/en/technical-article/000011137 rec=0 ...
1
vote
1answer
82 views

Trouble with creating new attributes on large shapefile?

I have a point shapefile with ~2.5 million points. I am creating a new attribute converting ft to m, and QGIS (2.18.15) is having trouble working with the datasets. I have seen suggestions to only ...
1
vote
2answers
183 views

Using Calculate Field to fix hyperlinks in ArcPy gives Cannot use VB for services?

Getting an error while trying to script it, specifically "Cannot use VB for services." Snippet and VB code block as follows: Raw block (works within ArcMap): "\ftp\raw\YYYYMMDD\Files\Charles" +[NAME]...
1
vote
1answer
76 views

Getting “real time” occurence count of values in attribute table for displaying purposes

I'm working with ArcMap 10.2 on a layer of points that I have to move. I'm using the editor to move them. What I also need is to display these points based on how many are sharing the same coordinates ...
1
vote
1answer
139 views

Reaching field value of record in ArcGIS field calculator?

I have two fields showing number of people in two age groups "young" and "old". these people also live in a cell (point) whose distance to a specific facility is calculated. then I categorized these ...
1
vote
1answer
2k views

Calculating polygon area inside another polygon in QGIS

Is it possible to calculate the area of colorful polygons (yellow, yellowish/reddish and red) inside another shapefile (purple outline, also polygons) in QGIS. For example the polygon that is marked ...
1
vote
3answers
4k 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(): ...
1
vote
2answers
226 views

Checking for values in one column and do something in another using ArcGIS Field Calculator?

I have two columns: "Street1" and "Verified". I need to check all rows in Street1 to see if they are of string "0" or null. I've attempted to come up with something in Field Calculator but it is ...
1
vote
1answer
2k views

Auto incrementing field that begins with text in ArcGIS Desktop? [closed]

I am searching for a way to auto increment an ArcGIS field which begins with text and followed by numbers. Ex. SWCL0000. I have tried the auto increment code in the field calculator but once I added ...
1
vote
1answer
1k views

Remove Leading Zeros with QGIS Field Calculator

I'd like to take this attribute value: "MAP_PAR_ID": "0160011000", and populate a new field with "16-11". This works: concat(substr("MAP_PAR_ID",0,3), '-', substr("MAP_PAR_ID",5,3)) but i need to ...
1
vote
1answer
1k views

How do I Calculate Grouped Percentiles or Batch percentiles in ArcMap?

My question is similar to this one which was answered successfully: Calculating Percentiles in ArcMap? My addition is how do I batch this solution for multiple files or apply a group-by feature to ...
1
vote
1answer
649 views

Create and immediately update field using Field Calculator

You can create fields and once created, populate them with data using the Field Calculator. But can you do both at the same time using an expression? Or must you do it in 2 steps?