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
52 views

Auto populate qgis file name with no file extension?

I'm looking to be able to auto populate an attribute field with the project file name either by a virtual field or default option in the properties. The "@project_filename" expression always produces ...
0
votes
1answer
23 views

Iterating over table to create chainages using Python in ModelBuilder

I routinely have to do the following workflow: Map GPS points;- Create lines based on those GPS points; Split the lines at a set interval distance (every 50m, every 100m etc.) Add from / to fields ...
1
vote
1answer
113 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'...
1
vote
2answers
59 views

Adding Hyphen between text in Python Parser of ArcGIS Field Calculator

I have list of numbers like this (S20170146) and I want to turn them to this format(S2017-01-46).Basically, I need to add "-" between the numbers. I am using Arcmap I know how to use feild calculator....
1
vote
0answers
33 views

QGIS $length returning incorrect values

BACKGROUND: At 3.8.3 I have several line shapefiles, each with CRS EPSG:2927. This is a CRS that I am familiar with, whose units are in feet. When I use the field calculator with $length to create ...
3
votes
1answer
90 views

QGIS Field Calculator provides incorrect answer when using the Maximum function

I'm using: The field calculator in QGIS I'm trying to: Find the winner of each election Problems: When there there is NO WINNER in an election, the field calculator incorrectly picks the ...
0
votes
1answer
42 views

Case - when in two layers

I'm trying to do an operation on a polygon layer to ask a different layer and if a condition is met then do an operation. It would be something like that: Case when ("DAP-OSM-BuildingsH-0m",'BuildCat'...
1
vote
1answer
27 views

ArcGIS Pro Field Calculator Python IF statement

I'm attempting to populate a newly created field with values dependent on an existing field. The new field has text data type. The existing field is double data type. This is the python code I've ...
2
votes
1answer
30 views

Using field calculator to populate one column using other data in same table in ArcMap

I'm not the best with using the field calculator of ArcMap and I'm unsure of what's wrong with my VBScript Basically the new column needs to contain data pulled from the same row in the following ...
0
votes
0answers
28 views

Updating Date Field based on date value ONLY from another field using ArcGIS Field Calculator

In ArcMap 10.4 I have the following code in Pre-Logic Script Code Section in Field Calculator with python option selected and show code block: from datetime import datetime def myfunction(date_text):...
1
vote
2answers
169 views

Multiplying values for each field with unique id

For one country I have population densities (highlighted with a red rectangular) per watershed literacy rate 4.48% (highlighted with a green rectangular) watershed IDs, e.g. 3222, 3271 etc. I'd like ...
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 ...
0
votes
1answer
52 views

Can't copy field to another: 'Empty value for Objectid = 0'

I tried to copy a field with dates that had type 'TEXT' to a new column of type 'DATE' because it is not possible to change the initial type of the original field. arcpy.CalculateField_management(r'...
1
vote
1answer
341 views

Computing long expression in ArcGIS field calculator?

I am trying to compute the following expression with the Field Calculator of ArcMap. The input table values are around the size of this value: 562643580,7843, and the field name (the field of ...
0
votes
1answer
27 views

Calculating New Field using Python Field Calculator From Two Fields Returning Specific Numbers

I have never used the SQL function in the field calculator and need some guidance. I am attempting to calculate new field data (date update) using python for a client that will look at first at one ...
0
votes
1answer
46 views

Calculating values in field to round up to 1 if value is greater than 0 using ArcGIS Field Calculator?

I am prepping vector data for raster conversion and analysis. In order to prep the data I need to have a field that represents data/no data (1/0). I built a model that outputs the necessary features ...
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 ...
-1
votes
1answer
45 views

What does if-else code do?

I just started a new job and in one of the procedures I was given for one of my tasks I found this piece of code. It just adds a comment to a field that's already filled up. For instance, field1 might ...
1
vote
0answers
31 views

QGIS: Update geometry via geom_from_wkt('POINT(X,Y)') - how to correctly parse string columns?

The columns containing X and Y strings look like -1234,56 So far i tried: geom_from_wkt(concat('POINT(',replace("wbr_komplett.X",',','.'),',', replace("wbr_komplett.Y" ,',','.'),' )')) and also: ...
2
votes
1answer
48 views

QGIS Measure Distance Using Field Calculator

I have a point shapefile with 80K+ records. Shapefile is projected in wgs84. The shapefile contains fields with the latitude and longitude of the point. I need a new field that contains a distance ...
2
votes
0answers
36 views

Auto populating attribute table with lat and lon in QGIS

is there a simple way (without writing script or Python skills) to auto calculate and auto populate lat and lon attributes in QGIS? When I manually add new points or move existing points in my layer,...
2
votes
1answer
37 views

Adding $length on the fly when adding line feature

is there a simple way (without writing script or python skills) to auto calculate and auto populate length attribute in QGIS? When I add a new line feature in my layer, I'd like the attribute length ...
1
vote
2answers
52 views

Filling attribute tables with values from the same attribute table

Just wondering if there's an easy way to fill null values in one column in an attribute table with values in another column of the same attribute table by just writing a query "just the "null values" ...
2
votes
2answers
44 views

Finding and replacing with if then else statement in field calculator of ArcGIS Pro?

I have a column of strings that always start with the first two characters being numbers, like 39 or 07, etc. In a new column I want to process the original column so that I replace any of those ...
3
votes
3answers
87 views

If any of B contains all of A, then count # of times A is in all of B

BACKGROUND: Long time reader, first time poster. Looking for help using QGIS to score data in a CSV table that was yielded from processing the contiguous neighbors of every polygon from a file with ...
0
votes
0answers
35 views

Adding minimum point Z of polygon using ArcGIS Field Calculator?

In the middle of a ModelBuilder tool I created, I have a Z enabled feature with multiple polygons. I want to add on a specific field of this feature, the lowest Z value of each polygon. I know this ...
9
votes
6answers
8k 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 ...
3
votes
1answer
63 views

Counting layer segments in QGIS Field Calculator

I have a segmented line (road) dataset and I want to get the number of times each road is segmented. In SQL it's just SELECT RoadMntnc, count(RoadMntnc) AS count FROM clip_DSC_Roads GROUP BY ...
1
vote
2answers
60 views

Calculating frequency in Field Calculator

I have a table with many instances of duplicate values. My end goal is to have three columns: "The Value": a file name. most are non-unique "Duplicate Instance": "this is the 1st time this file name ...
9
votes
3answers
3k views

How to convert a string field to a date field

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 to date field but ...
1
vote
2answers
58 views

Regex to get unique values in field using QGIS field calculator

I need to get the unique values from a field. (?<=,|^)([^,]*)(,\1)+(?=,|$) Works in an online test but I get invalid expression in QGIS Field Calculator. How can I rewrite this in QGIS Regex ...
1
vote
1answer
54 views

QGIS 3 Graphical Modeler field calculator with attribute's parameters

I want to make a model with a vector layer to calculate the sum of two parameters contained in the attribute table of the layer. I want to create two variables in the model, the name of the two ...
2
votes
1answer
151 views

Making output shapefile taking fields of input, and adding new field populated with list using PyQGIS?

I found a couple of good answers like here for example, but I do not manage to adapt them and make them work... What i am trying to do: take the input, create new output with same fields, add a new ...
1
vote
1answer
37 views

Extracting 2 groups of numbers from string in QGIS Field Calculator?

I have an attribute field that contains strings like "iuyluf45567kjyyr347fklj". All strings contain various amount of characters and digits (there is no clear pattern) but each string contains 2 ...
29
votes
4answers
23k 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, ...
2
votes
1answer
65 views

Difference between $x and x($geometry) [closed]

I just stumbled across something weird: I had point-data in EPSG:3059 and wanted to add the coordinates to the attribute table using $x resp. $y - which returned NULL. x($geometry) on the other hand ...
2
votes
1answer
326 views

Vector Fields as Input Variable in Field Calculator

I’m working with QGIS 3.2 Bonn and I try to build a workflow in the graphic modeler. The model aims to build variable buffers depending on values from two attribute fields of an input vector layer. ...
6
votes
6answers
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 ...
3
votes
2answers
5k views

Field Calculator returning incorrect length and area values

I can get accurate lengths of line features and areas of polygon features using the "Measuring Tool" in a QGIS project. However, when I attempt to generate length or area data in Attribute Tables ...
3
votes
1answer
486 views

Calculating Sinuosity Using ArcGIS Field Calculator

Trying to calculate sinuosity via Field Calculator (ArcGIS v 10.2.2); VBA Pre-Logic Script Code: Dim dblLe as double Dim dblLf as double Dim dblS as double Dim pCurve as Icurve Dim pFPoint as IPoint ...
3
votes
2answers
3k views

Calling variables within ArcPy functions using Calculate Field tool?

I have a defined function (ex. def my_function(x,y)). def my_function(x,y): """algorithm""" my_variable = my_function(filex, filey) How can I call this variable within the code block section of ...
1
vote
0answers
22 views

Getting less calculated area after merging/dissolving polygons [closed]

After I merge/dissolve polygons together, the area I calculated using the field calculator seems to decrease, in comparison to the calculation of each individual area and then summing it up. Can ...
3
votes
2answers
901 views

Adding both string and automated numbers in series to attribute table using ArcGIS field calculator?

I would like to fill a column in my attribute table with an string that ends in a numeric value. Example: Object001 Object002 Object003 I would like to automate the process of filling in the ...
1
vote
0answers
25 views

Reclassifying string variable in ArcGIS Field Calculator with Python Parser?

I am trying to calculate a roadway pedestrian restriction based on its functional class, using if/else logic in Python. Every time I enter this, it only turns up 'No'. The categories are strings, and ...
3
votes
1answer
50 views

Change data format in QGIS field calculator using format_date

I´d like to change the data format in the attribute table from yyyy-MM-dd (default) to dd.MM.yy using the format_date function in the field calculator. Using: format_date(date, 'dd.MM.yy') I got ...
4
votes
1answer
45 views

Evaluate string in field calculator QGIS

Is there any way to evaluate a string as an expression in QGIS. For example, I want to evaluate the string in Column 'hukg' as an expression.
4
votes
2answers
1k views

Transforming ArcGIS date field to integer?

I have a featureclass with a 'date' class field named 'ACQ_DATE' formatted as: 1-8-2013 24-7-2013 etc. As you can see the number of digits is not harmonized. I want to display the dates on a ...
5
votes
1answer
120 views

Counting number of features within another feature using aggregating function in field calculator of QGIS?

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 ...
3
votes
1answer
43 views

Coalesce field “X” if field “Y” is a duplicate

(QGIS 3.4) The image below will help explain my goal: I'm working out how to coalesce the attributes of the field "ID" if the field "X, Y" is a duplicate. I have highlighted some duplicate ...
7
votes
4answers
979 views

Parsing serial date in ArcGIS Desktop?

I have imported a shapefile that contains a serial date number that looks like this: 41256.260799. I would like to create a new field that shows only the hour and second like this: 06:33. I've tried ...