Questions tagged [python-parser]

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

Filter by
Sorted by
Tagged with
13 votes
1 answer
3k 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. ...
Becks's user avatar
  • 133
13 votes
3 answers
18k views

Calculating sequential numbers into sorted table using ArcMap

I am using ArcMap 10.3. Is there a way to calculate a sorted field with sequential numbers in the Field Calculator or using an Update Cursor in ArcPy? I have seen Sorting feature class to calculate ...
Midavalo's user avatar
  • 29.5k
9 votes
2 answers
21k 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 ...
Justin's user avatar
  • 3,390
19 votes
3 answers
108k 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 ...
BenW's user avatar
  • 613
8 votes
3 answers
24k 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 ...
yams's user avatar
  • 307
1 vote
2 answers
561 views

Using ArcGIS Field Calculator to create classes in new field?

I first classified firstCol into groups and then I want to give the groups with different weighted values in another field, SecondCol. I will need to give different weighted values very often. I find ...
NewHere's user avatar
  • 141
7 votes
1 answer
15k 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 ...
GIS Man's user avatar
  • 1,103
6 votes
1 answer
41k 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 ...
sirgeo's user avatar
  • 2,019
12 votes
2 answers
13k 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 ...
kaoscify's user avatar
  • 981
8 votes
2 answers
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 ...
djq's user avatar
  • 16.2k
14 votes
8 answers
59k 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 ...
artwork21's user avatar
  • 35k
6 votes
5 answers
21k 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 ...
tda's user avatar
  • 531
5 votes
2 answers
794 views

Script (ArcPy) vs field calculator (Python Parser) behaviour of getPart in ArcGIS for Desktop?

From time to time I have to access geometry field and shuffle through points in it. Process is simple: Get shape Get it's part Iterate through part's points This is how it looks like in a script ...
FelixIP's user avatar
  • 22.5k
4 votes
2 answers
13k views

Using conditional statements in ArcGIS Field Calculator?

I have two fields, "P_Area" and "PC_Area", whose sizes I'd like to compare in a third field, "Areas_Equal". The "Areas_Equal" field should contain a "Yes" if the other two are equal and a "No" if they ...
jay's user avatar
  • 337
0 votes
3 answers
6k 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(): ...
Stelios Tselepis's user avatar
12 votes
2 answers
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 ...
AlmaThom's user avatar
  • 844
7 votes
1 answer
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 :
sirgeo's user avatar
  • 2,019
6 votes
6 answers
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 ...
S. Burke's user avatar
  • 139
5 votes
3 answers
20k views

Calculating incidence angle of polyline using ArcMap

How can I calculate the angle of each polyline in ArcMap?
John Agbo Ogbodo's user avatar
4 votes
2 answers
9k views

Using nested if statements in Python Parser of ArcGIS Field Calculator?

The solution in VB for the base process is at If/then VBScript/Python code equivalent to SQL IN ('x','y',z') expression in ArcGIS Field Calculator? works great but I was trying to ...
GeorgeC's user avatar
  • 7,958
2 votes
3 answers
4k views

Using Calculate Field tool to calculate on null fields using ArcMap

I am using ArcMap 10.1. I want to use the Calculate Field tool in ModelBuilder on a table where, if field1 is null, it should take the value of field2. If field1 has a value then it should stay as ...
Steve's user avatar
  • 731
2 votes
3 answers
9k 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 ...
indybrown's user avatar
1 vote
3 answers
6k views

Replacing NULL values in geodatabase table?

How do you update NULL values within a geodatabase table using the ArcGIS Field Calculator (service pack 4) without changing other values to NULL? I've tried the suggestions on this previous question:...
artwork21's user avatar
  • 35k
1 vote
2 answers
974 views

Labeling using chemical formulas in subscripts that contain a mask in ArcMap 10.6

I would like to label points in ArcMap, and the labels contain chemical formulas. These chemical formulas have both subscripts and superscripts (see snip below) I am unable to use labels that both ...
Michael Rodney's user avatar
6 votes
2 answers
25k 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: !...
Cindy Jayakumar's user avatar
5 votes
4 answers
6k views

Concatenating numbers and adding in leading zeros

I have three text fields populated as follows: 1, 9, 1 that I need to concatenate into a field that looks like 01.09.01. Getting to 1.9.1 is easy but can anyone help out with how to formulate it so ...
Denyce's user avatar
  • 51
5 votes
2 answers
7k 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 ...
sirgeo's user avatar
  • 2,019
4 votes
2 answers
2k 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 ...
Haydlew's user avatar
  • 417
4 votes
2 answers
8k views

Field calculator if and elseif statement with <Null> values in ArcGis 10.1

Trying to figure out how to get this "Headwater" column to indicate "Yes" (or 1) if the value of "NextDown_Copy" is "" and "No" (or 0) if it has any other value (eg. 7100381010). I attempted to try ...
Dalal_EL_Hanna's user avatar
4 votes
1 answer
194 views

Recalculate a Field with data from another field, ignoring NULL values

I have a Feature Class in a Geodatabase with an field for pipe diameter. I also have a shapefile with a field for diameter. The shapefile is from field verification work that verified a variety of ...
LandArch's user avatar
  • 2,191
4 votes
2 answers
19k views

Replacing NULL value with Zero in geodatabase table using Python parser of ArcGIS field calculator?

I am having some difficulties to change "NULL" values to zero in geodatabase. I have tried the following python code in ArcGIS 10.1 ("Field Calculator") to change it but did not work. Pre-Logic ...
Amalesh Dhar's user avatar
3 votes
2 answers
5k views

Error msg "Name is not defined" when trying to populate a field with the shape file name

I am trying to populate a field with corresponding file name. For example, if the file name is Route1.shp then the field value will be Route1 as well. However my code is not working. Can you please ...
Python-Novice's user avatar
3 votes
2 answers
1k views

Calculating Z-scores using ModelBuilder in ArcGIS Desktop?

I am trying to take the natural log and then calculate z-scores on cell values in several composite band GRID rasters in ArcGIS Desktop. I am not fluent in Python and do not see a way to automate ...
Mo Correll's user avatar
2 votes
4 answers
830 views

Unable to replace Null values using Python parser of ArcGIS 10.0 Field Calculator?

I'm using the following python code to replace Null values by 0, using field calculator: def nulls(p1): if p1 is None: return 0 else: return p1 But nothing happens, Null values stay. I'm ...
AndM's user avatar
  • 383
2 votes
1 answer
2k views

Using Python if/then/else to return value from either of two fields based on value of third using ArcGIS Field Calculator?

I'm trying to avoid manually inputting Begin and End engineering station values already inputted into a seperate field. I'm dealing with(4) fields: Begin_Sta End_Sta Beg_End and Station. The ...
geo_mat's user avatar
  • 21
1 vote
3 answers
425 views

If/Then Field Calculator Return Calculations

After collecting GPS location for road culverts I would like to calculate the $ values for each culvert based on their diameter and length in ArcMap. Existing number fields in the attribute table are ...
Tom's user avatar
  • 33
1 vote
1 answer
168 views

Using python to convert string values with Calculate Field in ModelBuilder?

In ArcGIS 10.5, I am building a model that should convert a field of coded values to another code. This seems like it should be a simple if/then statement but I am not getting it. To simplify the ...
cpbride's user avatar
  • 374
0 votes
1 answer
7k views

Splitting field in ArcGIS field calculator using Python Parser?

I'm using field calculator in ArcGIS Desktop 10.2.1. I have field1 which has a values of "A_B" (example). I created two fields out of this, values to the left of the underscore go in fielda and to ...
Steve's user avatar
  • 731
-2 votes
2 answers
589 views

Writing python script to group and sum records from each group? [closed]

I am doing hydrology analysis in ArcMap 10.2 and have a drainage area feature class containing hundreds of records. Each record is assigned a drainage area name and acreage amount. How do I sum all ...
user89914's user avatar
18 votes
3 answers
38k 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. ...
jsmith's user avatar
  • 743
9 votes
4 answers
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 ...
ndthl's user avatar
  • 449
7 votes
4 answers
1k 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 ...
Gord's user avatar
  • 71
7 votes
1 answer
13k 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 ...
Solaire's user avatar
  • 151
6 votes
1 answer
2k 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 ...
Barrett's user avatar
  • 3,069
6 votes
3 answers
3k 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 ...
Natedawg5509's user avatar
6 votes
1 answer
17k 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.
tdr's user avatar
  • 247
5 votes
1 answer
679 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 ...
SteveC's user avatar
  • 745
4 votes
1 answer
617 views

Using ArcGIS Field Calculator to populate number field from text field?

I'm trying to assign speed values to street types using TIGER street shapefiles. So I created the new field for the speed, and I was going to use the field calculator to take the MTFCC classifications ...
Paul Cory's user avatar
4 votes
4 answers
14k views

Concatenating string data plus numeric data in ArcMap field calculator?

I am using ArcMap 10.2.2. I have three attribute fields (Address_No: 1, StreetName: Main, Street_Ty: ST) that I want to merge together. How do I concatenate string data found within the table plus ...
Snickers's user avatar
4 votes
1 answer
3k views

Python syntax error from raster calculator in ArcGIS ModelBuilder?

I am experiencing a problem with the raster calculator in the ModelBuilder under ArcMap 10. I need to combine two layers: a drainage map (issued from a series of previous operations on a DEM) and ...
Maxim L's user avatar
  • 49