Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [python-parser]

For questions about ArcGIS Python Parser for labelling expressions and field calculations

Filter by
Sorted by
Tagged with
17
votes
3answers
91k 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 ...
16
votes
3answers
29k views

Rounding column in attribute table using ArcGIS Field Calculator?

I want to use the Field Calculator in ArcMap to round an existing column to two decimals. Currently I have a column that is 6 decimal places long and would like to simply round it down to 2 decimals. ...
15
votes
7answers
9k views

Find/Replace Double Quotes using Python Parser of ArcGIS Field Calculator?

I'm trying to use the Field Calculator (ArcMap 10.0) to strip out double quotes in an address field (I didn't put them in there, believe me). I've tried many incantations but am still unable to even ...
14
votes
8answers
35k 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 ...
12
votes
2answers
9k 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 ...
11
votes
3answers
8k 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 ...
11
votes
2answers
1k views

Computing new attribute based on changes in another attribute using ArcGIS Desktop with Python?

I am attempting to classify a set of gps time-encoded point data into behaviors based on different attributes. I have created an attribute that is 0 for home and 1 for away based on location, and ...
10
votes
4answers
821 views

Need to find strings that contain the same word twice

I have attribute data with owner names. I need to select data that contains the last name twice. For example, I may have an owner name that reads "BENNETT MCCARL & ARNETTE BENNETT". I would like ...
10
votes
1answer
1k 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. ...
9
votes
4answers
7k views

Removing numeric characters from alphanumeric value in field calculation?

I have a field containing alphanumeric values in the following format: A-AA00 Sometimes they are also A-AAA0 I need a Python script I can put in the field calculator in ArcMap 10 that will at ...
8
votes
2answers
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 ...
8
votes
2answers
991 views

Changing default parser in ArcGIS Field Calculator to Python?

Is there a way to change the default parser in the Field Calculator to Python? So annoying to always change now that I'm trying to move away from using VBScript... I'm using ArcGIS 10.1 for ...
8
votes
2answers
19k 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 ...
8
votes
3answers
18k 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 ...
8
votes
2answers
850 views

Performing multiple calculations in ArcGIS Attribute Table?

I have an existing Excel spreadsheet developed to track specific fire hydrant data, this is periodically updated and joined to the spatial hydrant data in ArcGIS. In the spreadsheet there is a number ...
7
votes
2answers
3k views

Fnding wildcard string using Field Calculator script code?

I'm trying to find part of a text string in the CLASS_NAME field and return a text string to the Abrv_Name field using the Field Calculator in ArcGIS 10 via a Python parser. Here is what I have tried ...
7
votes
1answer
9k views

Meaning of exclamation mark in Python parser of ArcGIS Field Calculator?

In the following line, I don't understand what those exclamation marks mean? And why put everything in quotation? I don't understand the purpose of the variable expression, please explain to me as I'm ...
7
votes
3answers
4k views

Removing multiple characters from string field using Field Calculator Python Parser?

Is it possible to remove more than 1 character from a string in a field using the field calculator? I know !file!.replace(" ","") removes spaces in a string, but is it possible to remove spaces and ...
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 ...
7
votes
3answers
6k views

Calculating Field based on name of shapefile

I have multiple shapefiles to which I have added a field called "gname1". For each shapefile, I want "gname1" to be set to the name of that particular shapefile, for every feature within the shapefile....
7
votes
1answer
14k 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 ...
7
votes
1answer
2k views

Summing Attributes from a Related Table?

I have a line feature class representing road segments, with each road segment having a unique ID. This feature class has an attribute of average observed daily traffic counts. I have another table ...
6
votes
3answers
6k views

Doing If/Then over multiple data columns in Python Parser of ArcGIS Field Calculator?

I have some VB code saved that looks at two columns of data, and populates a third with the low value. Pre-logic Script Code: Dim output as double if [MIN_LEFT] < [MIN_RIGHT] Then output = [...
6
votes
1answer
3k views

Writing Python code block in field calculator?

I am a novice in Python as well has having minimal experience with ArcMap. Currently I am using a U.S. Census TIGER file, mapping roads in Harris County, TX. I want to add a new field called SPEED, ...
6
votes
3answers
980 views

Using degree symbol in Label Expressions of ArcMap? [closed]

I am trying to use the labeling process to display latitude and longitudes for a set of data points. To make the labels appear formal, I wish to add the degree symbol (°) to the labels. My python ...
6
votes
2answers
165 views

ArcMap sometimes ignores labeling expression

I'm using this python script as an expression for labeling in ArcMap: def FindLabel ( [volkorrekt] ): if [volkorrekt] >= '5': return "<FNT size = '20'>"+ str( [volkorrekt] )+"</FNT>...
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 ...
6
votes
2answers
19k views

Splitting string in Python parser of ArcGIS Field Calculator?

I am trying to use Python to split a string field into three new fields at the separator " - ". The field is in the format "a - b - c". So I initially had this in the field calculator for newFieldA: !...
6
votes
1answer
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 :
6
votes
1answer
645 views

Classifying time periods in new field using Python Parser of ArcGIS Desktop?

I have a datetime field (Horario) in my feature class, showing only the time. Although the date doesn't appear, it seem to be stored automatically as 30 Dec 1899, I'm not sure why. I want to use ...
6
votes
1answer
90 views

Update Cursor skipping last row?

I have created a python function within field calculator to calculate the time difference between a timestamp (yyyy-MM-dd HH:mm:ss) in a row and the row after (the interval field in seconds). I have ...
6
votes
1answer
3k views

ArcMap Field Calculator syntax (again)

I'm trying to string together a field calculator script that will populate all the records of a field at once based upon values in a number of fields. I can't even get the first part of the command ...
6
votes
2answers
5k views

Performing advanced labeling using Python in ArcMap?

I am attempting to write a Python label expression that would involve multiple label definitions. Here is what I am trying to do using ArcMap 10.1. I have a point shapefile representing Monitoring ...
6
votes
1answer
531 views

Python Labeling using dictionary not printing all values

I am labeling manhole inverts using python and ArcMap 10.3. When I use a dictionary to control the label order some manholes don't print all of the inverts while other manholes do. I can post field ...
5
votes
5answers
10k views

Normalizing raster using raster calculator in ArcGIS 10.3.1? [duplicate]

I have been trying to 'range standardise' or normalise my raster values from 0-100 and I know how to do this mathematically: ("raster"-min("raster"))/(max("raster")-min("raster"))*100 and I have ...
5
votes
1answer
36k 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 ...
5
votes
1answer
5k views

Converting state name abbreviations to full names using ArcGIS Field Calculator?

I have a data table with columns that includes city names (ex: San Jose) and state name abbreviations (ex: CA). Is there a way to define the state names as their full names (i.e., CA = California) and ...
5
votes
2answers
289 views

Field calculating a unique date and time

I want to field calculate a field to be have a have the date and time (down to the second) and two letters after (to be assigned by user). For example, if the record was created on September 8th, ...
5
votes
1answer
611 views

Translate Excel formula to be used in field calculator

I have a series of equations to create corner points to make rotated polygons based on angles in the attribute table, but I have created it in excel and can't figure out the syntax to get it to work ...
5
votes
2answers
6k views

If/then VBScript/Python code equivalent to SQL IN ('x','y',z') expression in ArcGIS Field Calculator?

we need just like the following, only with multiple records selected... have tried the "xyz" in (1,2,3,4,5) SQL code but of course VB Script wants something else. dim f2 if [field1] = "foo" then f2 ...
5
votes
1answer
161 views

Stacked Label using If/Else in a Label Expression

I have a large set of data with lab results that I'm looking to label in ArcMap. I'm trying to build a label expression that needs to produce a label that essentially needs to look like this: B=5 T=...
5
votes
1answer
569 views

Counting number of times value/string occures in field using ArcGIS field calculator?

How do I count the number of times a value/string etc. occures in a field (using field calculator)? In my example I want to count the number of times the letter "H" occures in a field; see attached ...
5
votes
1answer
125 views

Field Calculator text field to new shapefile

I have point features being selected by a polygon feature and copied to their own shapefile. I also have certain values of the polygon feature being applied to the newly created point file. The ...
5
votes
1answer
245 views

Calculating Polsby-Popper Score Using ArcGIS Pro Field Calculator gives ERROR 000539?

This operation is using the Field Calculator in ArcGIS Pro 2.1. I am trying to calculate the Polsby-Popper Score for Congressional Districts. I have calculated the Geodesic Area and Geodesic ...
5
votes
1answer
330 views

Extracting partial data from one field to another using Python Parser of ArcGIS Field Calculator?

I am attempting to extract a date stamp that is contained in one field and insert it into another field. The issue is that the date (in bold below) is not in the same location in each line of the ...
5
votes
2answers
573 views

FindLabel not Defined in ArcMap labeling with Python Parser?

I'm trying to make an advanced label expression using the python parser and I keep getting the following error: The expression contains an error. Modify the expression and try again. Error 0 on ...
5
votes
1answer
177 views

Using a loop in a python expression to stack labels while avoiding zero value attributes

I have a number of point features in a map in ArcMap 10.6 that I would need to label based on information form three fields (Test1, Test2 and Test3) with numeric values. The labels from these 3 fields ...
5
votes
0answers
54 views

Updating null geometries from attribute using ArcGIS Field Calculator? [duplicate]

I have a large point feature class and have realised that there are several hundred features with null geometry. Fortunately the coordinates are stored as an attribute. What I need to do is update the ...
4
votes
2answers
180 views

Arcmap field calculator python script returns no data

I am running ArcMap 10.2 I have 4 fields with which I am working. many have duplicate entries. in order to find the single correct entry from all the duplicates I am trying to calculate out the ...
4
votes
1answer
12k views

Deleting first two letters from string field usimng Python Parser of ArcGIS Field Calculator?

I'm looking for a field calculator Python statement to delete only the first two letters of string entries. For Ex: !Name!.strip([0:2]) I know this syntax is incorrect.