Questions tagged [python-parser]

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

Filter by
Sorted by
Tagged with
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. ...
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 ...
11
votes
3answers
7k 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 ...
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 ...
1
vote
2answers
256 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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 :
3
votes
3answers
12k views

Calculating incidence angle of polyline?

How can I calculate the angle of each polyline in ArcGIS?
2
votes
3answers
7k 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 ...
1
vote
3answers
5k 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:...
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 ...
4
votes
2answers
614 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 ...
4
votes
2answers
8k 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 ...
4
votes
2answers
11k 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 ...
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 ...
3
votes
3answers
3k views

Using Calculate Field tool to calculate on null fields?

I'm using ArcGIS 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 is.
1
vote
2answers
330 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 ...
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 ...
2
votes
1answer
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 ...
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: !...
3
votes
2answers
4k 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 ...
2
votes
1answer
4k views

Converting field to string with leading zeroes using Python Parser of ArcGIS Field Calculator?

I would like to create an expression using the field calculator in ArcMap to be able to convert an Int field to a string and add leading zeroes. I am able to do it in a python window with an example ...
4
votes
4answers
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 ...
4
votes
2answers
15k 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 ...
4
votes
1answer
79 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 ...
4
votes
2answers
1k 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 ...
3
votes
2answers
875 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 ...
2
votes
4answers
608 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 ...
2
votes
2answers
3k 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 ...
1
vote
1answer
85 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 ...
1
vote
3answers
242 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 ...
0
votes
1answer
3k 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 ...
-2
votes
2answers
370 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 ...
6
votes
3answers
974 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 ...
16
votes
3answers
28k 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. ...
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 ...
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 ...
6
votes
1answer
528 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 ...
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.
4
votes
1answer
2k 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 ...
4
votes
2answers
2k views

Writing If-Then Statement in ArcGIS Field Calculator using Python Parser?

Scenario: I have four fields: A, B, C and D Field A is text-based and contains values from '000' up to some number 'xxx' Field B contains a set of values (also text, but represented by numbers) ...
4
votes
4answers
9k 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 ...
4
votes
1answer
528 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 ...
3
votes
1answer
685 views

Field Calculator: Split address into house number, street name

I have an ADDRESS field in a table with values like: 1 MAIN ST 20 SIDE AVE W 300 JOHN DOE JR RD S I want to use the field calculator to split the addresses and insert the parts into HOUSE_NUMBER and ...