Questions tagged [python-parser]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
327 views

Labeling Count values from Arcgis attribute field

Today at work I was facing some challenges to Label the count values from attribute tables of the feature class. We have all the data stored in geodatabase that is server based. I wrote python code in ...
1
vote
1answer
85 views

Using label properties/expression in ArcMap to label several ranges of numbers within feature class red?

I have about a thousand labels, some of which need to be labeled red. For example, 511-533 and 659-671 need to be labeled red, and the rest can be labeled in black. They are all part of the same field ...
1
vote
1answer
2k views

Auto incrementing field that begins with text in ArcGIS Desktop? [closed]

I am searching for a way to auto increment an ArcGIS field which begins with text and followed by numbers. Ex. SWCL0000. I have tried the auto increment code in the field calculator but once I added ...
1
vote
1answer
310 views

Performing If Statement in Python Parser of ArcGIS Field Calculator?

I've one field "MAXSPEED". I want a Field Calculation that will calculate an additional field ("noise"): If MAXSPEED > 40 then the term: (73.5 + Log ( 25 ) * ( [MAXSPEED] / 50)) should be used to ...
1
vote
3answers
486 views

Calculate Field with Python Parser an If statements?

I don't know a whole lot about python and scripting, so I was hoping somebody could give me a couple pointers on fixing some code. I am trying to calculate a "final results" attribute field. The ...
1
vote
1answer
1k views

trouble with code block execution in python script

I am trying to calculate values for a field in a python script, but keep getting an error that I don't understand: ExecuteError: ERROR 000539: Error running expression: Fron000000F1 Traceback (most ...
1
vote
1answer
242 views

Python codeblock not recognizing field?

I've been through multiple iterations / gyrations, and while there may be multiple problems here, the recurring issue is that the codeblock does not identify the existence of any syntax errors, but ...
1
vote
1answer
586 views

Returning end of string up to certain character using Python Parser of ArcGIS Field Calculator?

I am trying to accomplish this task: https://stackoverflow.com/questions/15851568/how-to-get-the-last-part-of-a-string-before-a-certain-character within the Field Calculator. I have the below but ...
1
vote
4answers
333 views

Calculations in if statement

I want to perform a simple calculation with the Field Calculator using this piece of script (note that all the elif statements are attempts for another syntax and non of the worked): def change(...
1
vote
2answers
33 views

Adding time to variable using Python Parser of ArcGIS Calculate Value tool?

I am using Python 2.7 in calculate value in ModelBuilder. I want to query both 30 seconds before and after the variable. The original value keeps returning not the time change. What am I not defining? ...
1
vote
1answer
45 views

Autoincrementing one character in calculate field of ArcGIS Pro?

I am using ArcGIS Pro. I have this set of points where I like an unique id (uid). The only thing they need to be unique is a counter of some sort at the end. I have another field with some id that ...
1
vote
2answers
112 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?
1
vote
2answers
67 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): ...
1
vote
2answers
213 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
1answer
93 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 ...
1
vote
1answer
84 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 (...
1
vote
1answer
228 views

ArcMap - Field Calculator / Calculate Value - extract month of median date between two dates

I have a String field 'INTERVAL' giving the two dates used for a difference image in the form "YYYYMMDD_YYYYMMDD". I would like to populate a second field 'MONTH' giving the month of the median date ...
1
vote
2answers
235 views

Conditional statement in field calculator using Python parser ArcGIS

I have looked at many threads on here asking about coding nested if-then or conditional statements in field calculator in ArcGIS. This seems to be a common problem for beginner programmers. I've ...
1
vote
3answers
160 views

Batching Python script in ArcGIS field calculator?

I know nothing on scripts- learning as I go, I have a point shp file that has a column named SUFFIX in the column the words are spelled out AVENUE, ROAD, STREET, SQUARE and so on. Therefore I'm using ...
1
vote
2answers
845 views

Changing Format of Date Field in ArcMap Field Calculator?

I am trying to change the format of date field using ArcMap field calculator. My data is currently in the format "%d/%m/%Y %h:%m:%s" (e.g. 5/05/2016 12:25:46 AM) I want to change this to "%d/%m/%Y" (...
1
vote
2answers
249 views

Field Calculator Parsing error SyntaxError: invalid syntax (line 2)

I'm writing a conditional in the Field Calculator and it's giving me an error of syntax in line 2. Can someone see it? The Code Block is this: def ZFactor(LAT_CENTR) : if (10.000 < math.fabs(...
1
vote
1answer
127 views

Parsing Address in Field Calculator

I'm trying to parse up the addresses in a table using the above code. It runs but only produces NULL. I have run out of ideas
1
vote
2answers
10k views

TypeError: coercing to Unicode: need string or buffer, NoneType found in ArcGIS labeling?

I have found out how to label using multiple attributes via an expression and python. What I have is as follows: [ID] + '\n' + [Notes] An ID example is "MH108" and a notes example is "buried, no ...
1
vote
1answer
279 views

Converting label expression from VBScript to Python in ArcGIS Desktop?

I have a feature class with label expression in VB script. I do not have the skill to convert a VB script to a python script. Here is the VBScript:- Function FindLabel ( [DESCRIPTION] ) if (left(...
1
vote
1answer
516 views

Deleting Blank Spaces in Excel sheet before Importing to Table?

I have developed a model that imports an excel sheet and converts it into a table. It then joins values within this table to a particular feature class. I then use the calculate field tool to copy ...
1
vote
1answer
394 views

Add classification value to attribute table?

I am trying to create a score for values in a table based off where the values fall within a classification range. Have: Attribute table with income, range= $29,725 - $76,996 Layer Properties ...
1
vote
2answers
838 views

Getting days of week from date field, with field calculator? [closed]

I'm using ArcGIS 10.3.3 and have a field containing a date as following format M/D/Y. I need to get the day of the week based on my date field. I need to do this from the field calculator. Example ...
1
vote
1answer
549 views

Avoiding multiple elif statements in Python parser for ArcGIS label expressions?

My code for labels look like this: def FindLabel ( [NAME_GEO] ): if [NAME_GEO]=="Tbilisi" : return "<BOL><FNT size ='14'>" + [NAME_GEO] + "</FNT></BOL>" elif [...
1
vote
1answer
69 views

ArcGIS - if clause in the field editor with python

I have 2 columns in my table. "dB1" and "dB2" Now I want to calculate a third columnn "dB3" depending of the entries in column "dB1" and "dB2" if "dB1" or "dB2" have an entry of "0" I want to ...
1
vote
1answer
118 views

ArcMap function in field calculator not working

Trying to return everything except the last element in a field after splitting it. Using ArcMap 10.2.2 in the field calculator. !ST_NAME!.split(" ")[:-1] This returns a null value in attribute ...
1
vote
3answers
1k views

Script for Sum of Rows in field calculator - VB or Python?

I wrote the TOTAL_FREQUENCY values manually. But I want to automatically write this values with a script. Namely, I want to write sum of column 3 to all of the the column 5 rows. How can I do it with ...
1
vote
1answer
49 views

Python not appearing as option for parser in label expression dialog of ArcGIS Desktop 10.0?

I have ArcMap 10.0 and python is not appearing as a parser option in the label expression dialog box, only VBScript and JScript. Python is installed and the python window works fine. Any idea how I ...
1
vote
1answer
224 views

Iterating through list of fields using field calculator?

import arcpy, sys, itertools arcpy.env.workspace = r'path to geodatabase' fields1 = ['gearqty', 'cnemarea', 'fzone', 'qdsq', 'tensmsq', 'crew', 'nanglers', 'port', 'totalquant', 'trip_days', '...
1
vote
1answer
142 views

Assigning values to field based on values in other field using Python Parser of ArcGIS Field Calculator? [duplicate]

I have a table with two fields A and B, and i want fill field B with "some values" from field A: FieldA: 123456_CC; 123_D; 1234567_AB; 123456768_F I just need the "text" that is associated with the ...
1
vote
1answer
831 views

Null output from field calculator code block

I have a simple calculation to compare two columns and populate a new column with the lower value but I am getting null output...any ideas? expression re_score(!Signal_Strength!,!Signal_Strength_1!,...
1
vote
1answer
371 views

How to tranform a column field into a list using Field Calculator

I'm trying to make a simple field calculation with ArcGIS 9.3: New field = Old field - Old field(first value) which in Calculate Field with python code should be Expression: !Old field! - first ...
1
vote
1answer
51 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 ...
1
vote
2answers
130 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
1answer
34 views

Auto incrementing every second row in ArcGIS Desktop?

How do I auto increment every second row (field type is short and I work with 150 fields) in ArcGIS Desktop 10.3.1? I saw this code in https://support.esri.com/en/technical-article/000011137 rec=0 ...
1
vote
1answer
85 views

Reclassifying field using Python wildcard string search?

I have a point layer with 900K Tree Point records. In that layer I have field (d_Species) that contains the tree species of each record. I've created a field (SpecieValu) to assign a value (0-3) for ...
1
vote
1answer
40 views

Using Python Lists in Calculate Field Code Block? [closed]

I'm looking for some help in explaining what exactly is occurring with the following code: MaterialLife = "LifeMaterial(!"+Material+"!)" codeblock2 = """def LifeMaterial(mat): material = {"ABS":...
1
vote
1answer
44 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 ...
1
vote
1answer
39 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
1answer
30 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
1answer
30 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!...
1
vote
1answer
290 views

ArcGIS Field Calculator Not Working With Date Field

I am trying to calculate a field based on the date values in another field. Here is my code from the pre-logic script code box: def getHalf(dfield): if dfield >= date '2017-08-27 00:00:00' AND ...
1
vote
1answer
133 views

Creating If Then statement in Field Calculator between 2 values? [closed]

I have a FC with a column for NEAR_ANGLE from the output of the NEAR tool. The angle is displayed in degrees (i.e. -154.67687) which is fine. I am trying to create a column, HEADING, that reads this ...
1
vote
1answer
59 views

Populating comment field using Python Parser of ArcGIS Field Calculator?

I am new to using Python and seek help building a code for an ArcGIS project. I took one introductory C programming course in school, but other than that I am green. My objective is to have the ...
1
vote
1answer
130 views

Multiple Conditionals String with ArcGIS Field Calculator?

I am trying to use Field Calculator to use a multiple conditional based on a string in another field of the same attribute table. I have written the code below, but without success. Pre-Logic Script ...
1
vote
1answer
97 views

Calculate number of alpha characters in field to a new integer field - ArcGIS [closed]

In a feature class field (screenshot below), I'd like to know how I can get a count of the alpha characters in each record and calculate it to a new field. I have a "FieldCount" field that calculates ...