Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [python-parser]

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

3
votes
2answers
103 views

How to Refer to a Null value with ArcPy Expressions

I feel like this might be a bit of a simple answer but I can't figure out how to refer to Null values in a field using an expression in python. I've tried using the following as well as = None and =...
0
votes
1answer
31 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
1answer
29 views

How to turn a string field with 2 numbers in two numerical fields in the atribute table?

I have a feature class with a big number of features. In the attribute table I have a string field made from two numbers separated by an underline (e.g.: 0_1, 98_237, 31_31...). I want to create two ...
2
votes
2answers
123 views

Converting none to zero (0) in geodatabase table using ArcPy?

I have an attribute table looks like this How do I convert Nulls into 0? I've tried to set this table non nullable type but got this: while the official doc says this: At least one of them is ...
0
votes
2answers
61 views

Concatenate fields (double and string) to create address using arcpy

fields: STNUM = double STRDIR = string STRNAME = string STRTYPE = string Tuple and s.format I have tried: arcpy.CalculateField_management (newparcelsUTM, "SiteAddress","{0} {1} {2} {3} ".format('!...
4
votes
3answers
198 views

Converting full road names to abbreviation using ArcGIS field calculator?

I have a data table with a column 'names' that have street names with street type (Road, Lane, Street etc.). I need to get the names in a format like in column 'new_names'using field calculator in ...
0
votes
1answer
23 views

Splitting second word of attribute using Python Parser of ArcMap Field Calculator?

This is Field Calculator in ArcMap. I am trying to split the word after the first space if the words starts with "San" like San Francsico, San Diego and etc. It return an error. Below is the script.
1
vote
0answers
28 views

Is there a way to use the project layout if using a plug in that creates batch maps through QGIS?

There is a plugin for biological records which creates batch maps for each taxon but it bypasses the premade project layout with a legend, picture of a logo and the copyright for each of them. Is ...
2
votes
1answer
46 views

ArcGIS Pro Field Calculator completing without error, but no change to Feature?

I'm attempting a research project in which I am seeking to categorize a municipality's Property Use Codes as Generalized Land Uses. For example, "AGRII - Developed Farmland" and "INDGR - Grain ...
0
votes
3answers
39 views

Making one field/values equal to another field/values

Lets say I have created a new field called "SFX" in a shapefile called "myshape.shp": input = r"C:\files\myshape.shp" arcpy.AddField_management(input, "SFX", "TEXT", field_length=100) There is now ...
0
votes
1answer
24 views

Add default month/day to known year in new date field?

I have a text field featuring a 4 digit year. How would I assign a default month and day to the year in a new date field? ex. 2010 needs to be converted to 1/1/2010 I attempted this in the field ...
2
votes
1answer
84 views

Using Python Dictionary to label subscript formatting ArcMap 10.6

*Question updates at bottom I need to label chemical formulas out of the attribute table but the attribute table doesn't recognize anything but plain text. THEREFORE I have built a dictionary ...
2
votes
3answers
67 views

Using IF/ELSE Statement for field calculation in ArcPy?

I would like to calculate the slope value in %, but I don’t want to have any negative values. If there are negative values in the slope field, I would like to multiple them by -1 and if not, multiple ...
2
votes
0answers
39 views

Using Python nested if statement for labels in ArcMap?

I am trying to use python to write a label expression that will display a specific set of labels based on nested if statments. The expression should result in a 4 line label if the value is greater ...
0
votes
1answer
44 views

Creating label with number circle and field “1v” in ArcMap?

How to create a label which combines a circle number and field "1v" in ArcMap? For example: I need, a line the labels. My code label expression is: Function FindLabel ( [TOTAL_VIV] ) FindLabel = "&...
1
vote
1answer
25 views

Python Group by attribute range

I have about 6000 points that I need to run a computationally intensive analysis on. My thought process is to break this point layer up into six groups of 1000 points each. I'm trying to do this in ...
1
vote
2answers
66 views

Converting numbers 1,2,3,4 to 001,002,003,004 [duplicate]

How can i convert a field 1,2,3,4... to 001,002,003,004...010...? For example 1 change to 001 2 change to 002 3 change to 003 ... Is there any formula in field calculator?
2
votes
1answer
39 views

Calculating field on if-else-condition checking input parameters for <Null>?

I want to calculate a field depending on 3 input string parameters. Two of them can contain Null-values. My old VB expression was not able to work with Null-values, so the script stopped. Now I want ...
4
votes
1answer
98 views

Writing Labeling Expression for ArcMap?

How can I remove the alphabets and show the numbers only in a label expression of a layer? For example, I have a field with values: TK209, 01TKRW394, 045TK, 089EYZ46 and I want to display labels as: ...
1
vote
1answer
36 views

Field Calculator Python Code for Between X-Y Calculation

I am trying to identify category based on two continuous variables and using IF ELSE logic for this. I intent to add elif statement, but even this code is throwing script error. Both attributes are ...
1
vote
3answers
90 views

Writing advanced label expression for ArcMap?

I have a label that I need to format using label expression. The label looks like this: EVA09C and I want the outcome to be this: EA09C Can I tell the label expression to skip the V in there?
0
votes
1answer
197 views

ArcMap field calculator error 000989 indention error?

I'm trying to make a four character output based on concatenating a single character field (in1) with either 1 or 2 zeros, depending on the length of in2, and then concatenating that . I'm getting an ...
3
votes
4answers
184 views

Concatenating address fields with possible blank or null values in fields using Python parser?

The following Python code is what I have already tried in field calculator of ArcMap 10.5.1: Pre-Logic Script Code: def ConcatAddr(!JOIN_KEY!) val = "" if !Address! <> val ...
0
votes
1answer
34 views

Combining string and returned value in label of ArcMap?

Using ArcMap 10, I am trying to label features with the first character in from the field "label." I can get it to return the first character, but I want the label to be Div L, Div X, etc.... Here is ...
0
votes
3answers
115 views

Advanced label expression in ArcMap to exclude part of a string

How do I write an advanced labeling expressions to only show a part of a string? I want my data that looks like this EVA007 only to show the 007 part.
0
votes
1answer
46 views

ArcMap label expression returning NoneType error

I'm trying to create street range labels rounded to the nearest 100 unless a street range is less than 100 I'm using "50". I have a field l_refaddr that is a string with number ranges for a street ...
1
vote
2answers
36 views

Merging duplicated fields within merged layer using ArcMap?

In ArcMap 10.6, I'm merging a series of layers with shared attribute fields. After I merge, every field is duplicated instead of combined, so it looks like this (real thing too wide for screenshot): ...
0
votes
3answers
38 views

Trying to clip many layers using Python in ArcMap, getting error that an output already exists

I have a nationwide shapefile I want clipped into regions. There's not so many regions that I need to script iterating through each region, but there are enough where I want to batch process this. I ...
1
vote
2answers
167 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 ...
1
vote
1answer
35 views

Python Labelling in ArcGIS - Two Languages one string

I am trying to format a label in two languages in a way they appear on one line and not stacked in ArcGIS any ideas? Maplex Stacked label feature is not ticked so this does not help. This is how they ...
1
vote
0answers
75 views

Auto-Refresh Field that has been Calculated with Python in ArcGIS Pro

Is there a way to get a calculated field to auto-refresh? For example, I have an expiration date field with dates filled in. I have another field that I will use to show the number of days left till ...
2
votes
1answer
349 views

Writing If-Then statement in ArcGIS Pro field calculator using Python?

I've been using ArcGIS Pro over ArcMap recently because ArcMap is giving me some incorrect summary statistics that I use to populate a data field in a number of feature classes. The problem is that I'...
1
vote
1answer
27 views

Failed to Generate Incremental ID with Following Python Code in the Code Block. What's the mistake in my code?

I am trying to add a field with incremental ID for a shapefile with certain feature classes. I know this can be done by using Sort tool and then use the Add Incremental ID field tool. But since I'm ...
1
vote
3answers
154 views

“Length” field needs “ft” added to end of each number!

I have a field for "Length" regarding some data collected in the field. Unfortunately the "ft" after the number for the length had spaces or no spaces or a weird format, but basically I want Length to ...
0
votes
1answer
51 views

Using Field Calculator to auto-increment in ArcMap?

I am trying to edit the basic sequential numbers in a field script using Python in the Field Calculator. I set the Parser to Python, and for my Pre-logic Script: rec=0 name="manhole" def ...
1
vote
2answers
68 views

Removing part of string in ArcMap using Python? [closed]

I have a Field in this table which reads, and this is a sample because there are over 82,000 tracks in this county, "40 acres". I do have this Script which I know took the "Acres" portion out of the ...
1
vote
0answers
40 views

ArcGIS field calculator pythons script value transfer between columns [closed]

In the picture below I can transfer values from one field(FID) to another(Id) using ArcGIS. The issue is that I will end up with some duplicated values in field "Id" (example number 12 and 17). My ...
0
votes
1answer
77 views

Calculate sequential ID field using ArcGIS Field Calculator? [closed]

In this example, previously posted as Calculating sequential numbers into sorted table using ArcGIS Desktop? : How do you construct a Python code that would give the Seq field sequencing such as: ...
1
vote
1answer
61 views

Use if statements in Calculate Field Code Block to give features in a field different values

I've been self learning Python. Now I want to play a little with the Python code block so I can be more comfortable building my own expressions later on. Right now I am just playing with this water ...
-2
votes
1answer
52 views

Field calculator in ArcGIS 10.4 multiline python code

I am trying to use field calculator to calculate a field based on unique types in another field. I had to go for a for loop to add new values. I have 81 classes and every class should be assigned an ...
0
votes
1answer
97 views

Using arcpy to set a Python expression for Label Expression

I have a python script that I input into the label expression by hand which assigns different labels depending on the attribute data, see: def FindLabel ( [a], [b] ): if [b] != 'ok' and [b] != '...
5
votes
1answer
120 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 ...
1
vote
2answers
95 views

Labelling using Python Parser in ArcGIS Desktop?

I have limited expertise with Python. I need to create labels based on groups of attributes. I've figured out a clumsy way to accomplish this but it involves 20 different annotation classes / SQL ...
0
votes
1answer
200 views

Replacing text in label expression of ArcMap?

I'm trying to replace the text in a field to build a label expression. The field I'm using is called [Organizatio] and it holds the school's name. What I want is to tell ArcMap that when that name ...
1
vote
1answer
58 views

Field Calculator runs without error, but does not populate desired fields

I have merged numerous datasets that have the same attributes in different fields. I have TotalAcres, Total_Acres_Burned, TTL_ACRS, etc... I am trying to use field calculator to populate one field (...
2
votes
1answer
52 views

split attribute using ArcGIS Field Calculator

I have a long string in one attribute. I want to be able to extract a small portion of it into a new attribute. This is an example of the attribute: "< html xmlns:fo="http://www.w3.org/1999/XSL/...
1
vote
1answer
252 views

Field calculator to calculate if field contains certain text

I have a field (WS_Type in the screenshot) that I want to use to calculate values based on the text within the field. The number of occurrences of each WS_Type in the field is not important, but the ...
1
vote
1answer
23 views

Classifying text field 'B' using integer in field 'A'?

I wrote an if elif statement that will loop through records (field A) and populate a new field (field B) based on A's contents. Field A name is 'CLASS'. Field B is 'class_desc'. reclass(!class_desc!...
0
votes
2answers
46 views

How do I .replace/remove within labelling [closed]

I would like to remove N_A and N123#N123 from my Labels. How do I do that? So far: str([RTN]).replace('N_A',' ') I still Need to remove the eg. N123#N123 as well from the Labels, but keeping the ...
1
vote
4answers
80 views

Using ArcGIS field calculator with if else to populate field?

ArcMap 10.4.1 on Windows 7. I am trying to fill in some blank rows in a column using field calculator. The field I am trying to fill is: label. If it is empty I want it to be populated with a value ...