Questions tagged [python-parser]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
30 views

Writing if/then Statements for Python Parser of ArcGIS Field Calculator

For some reason I cannot get this code to work in the Field Calculator of ArcGIS Desktop 10.6.1. I'm trying to use the Python parser to populate the field "SHAP_CLAS" with multiple conditional ...
1
vote
1answer
32 views

Python code snippet to label years (e.g. 2015) and not label anything with a 0

I've been unable to solve this seemingly rudimentary issue of running a python snippet via the label expression option in ArcGIS. I've read this documentation Building label expressions, but wasn't ...
0
votes
0answers
18 views

Calculating Field from text to integer using ArcMap [duplicate]

I'm using ArcGIS 10.7 trying to calculate a speed field (for my data of roads in California) really simply such that roads = 45 and highways = 65. I know I need to use an if then statement but I'm not ...
0
votes
0answers
34 views

Using Calculate Field in ArcGIS Pro

I have several field in an attribute table that have value, I am wanting to using the 'Calculate Field' GP tool to select the values and replace them with zero. Anyone have any ideas on the Python ...
1
vote
0answers
25 views

Calculating values for new field using values from another field as values in dictionary?

I am using the ArcMap application of ArcGIS Desktop 10.5. Im trying to use field calculator to return a max value between other fields in the feature based upon a condition. I am not new to python, ...
0
votes
0answers
15 views

AutoIncrement based on Field Value [duplicate]

Is there any way to automatically restart the AutoIncrement () function based on the Field Value on ArcMap? I am developing a model in ModelBuilder to name parcels automatically. The polygons are ...
0
votes
1answer
60 views

Adding spaces in string using Python parser of ArcMap field calculator

I am using ArcGIS Desktop 10.6. I have a integer field [no_lot] which contains values in the following format: '3 546 777' I need to transfer the data into a text field for joining purposes. I ...
1
vote
1answer
45 views

Calculating fields (multiple) with different conditions for each field using ArcGIS Pro

I have a population dataset where I want to reclassify the age groups and include gender. I have the field "gender", 1 for men and 2 for women, and the field "age". One row for each person in the ...
0
votes
1answer
31 views

Adding two to every value of field using ArcMap Field Calculator

I am working on a road network and each section is assigned a certain value and increases by 1 each section until it gets to around 500 which is the end. A change I had to make was adding two ...
0
votes
1answer
33 views

Iterating over table to create chainages using Python in ModelBuilder

I routinely have to do the following workflow: Map GPS points;- Create lines based on those GPS points; Split the lines at a set interval distance (every 50m, every 100m etc.) Add from / to fields ...
1
vote
1answer
55 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
161 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....
0
votes
0answers
30 views

Updating Date Field based on date value ONLY from another field using ArcGIS Field Calculator

In ArcMap 10.4 I have the following code in Pre-Logic Script Code Section in Field Calculator with python option selected and show code block: from datetime import datetime def myfunction(date_text):...
0
votes
1answer
32 views

Calculating New Field using Python Field Calculator From Two Fields Returning Specific Numbers

I have never used the SQL function in the field calculator and need some guidance. I am attempting to calculate new field data (date update) using python for a client that will look at first at one ...
0
votes
1answer
54 views

Calculating values in field to round up to 1 if value is greater than 0 using ArcGIS Field Calculator?

I am prepping vector data for raster conversion and analysis. In order to prep the data I need to have a field that represents data/no data (1/0). I built a model that outputs the necessary features ...
-1
votes
1answer
46 views

What does if-else code do?

I just started a new job and in one of the procedures I was given for one of my tasks I found this piece of code. It just adds a comment to a field that's already filled up. For instance, field1 might ...
1
vote
2answers
57 views

Filling attribute tables with values from the same attribute table

Just wondering if there's an easy way to fill null values in one column in an attribute table with values in another column of the same attribute table by just writing a query "just the "null values" ...
2
votes
2answers
49 views

Finding and replacing with if then else statement in field calculator of ArcGIS Pro?

I have a column of strings that always start with the first two characters being numbers, like 39 or 07, etc. In a new column I want to process the original column so that I replace any of those ...
0
votes
0answers
38 views

Adding minimum point Z of polygon using ArcGIS Field Calculator?

In the middle of a ModelBuilder tool I created, I have a Z enabled feature with multiple polygons. I want to add on a specific field of this feature, the lowest Z value of each polygon. I know this ...
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? ...
0
votes
2answers
35 views

Creating conditional stacked labeling in ArcGIS Pro?

I found a code example for what I'm looking to accomplish at Creating conditional stacked labeling in ArcGIS Pro? I want to display filter quantity and sizes for a school district per building in a ...
1
vote
0answers
36 views

Reclassifying string variable in ArcGIS Field Calculator with Python Parser?

I am trying to calculate a roadway pedestrian restriction based on its functional class, using if/else logic in Python. Every time I enter this, it only turns up 'No'. The categories are strings, and ...
2
votes
1answer
46 views

Keeping only 7 digit number within field name using ArcGIS Pro field calculator and regex

I have a field titled GEOGRAPHY, which contains hundreds of records containing various strings of all similar format, for example: "Witless Bay (1001559) T 00000 ( 6.5%)" "Laniel (2485905) NO ...
0
votes
1answer
29 views

Pulling date from filename and in proper format for time enabled use?

My feature attribute table has a folderpath that indludes a date time. Example:/documents/foldername/xyz2015OCT15063333.shp It seems very simple, but I am not a programmer and have done my best to ...
0
votes
2answers
48 views

Calculate time duration from military time with ArcMap Field Calculator [closed]

I have two text fields (STRTTIME, ENDTIME) which are are formatted as military time with leading zeros. For example, 0540, 1655. I want to calculate a new field with the time duration as integers (...
2
votes
1answer
52 views

Using If statements to conditionally populate a field in Field Calculator

I'm trying to use the field calculator to poplulate a string field in a table based on info in another string field. This is what I have: def Reclass(Correction_Comments): if (MSAGSTREETNAME) = '...
0
votes
0answers
62 views

Converting Python to Arcade in ArcGIS Online?

The following python expression can trim street addresses for labeling in ArcMap. I need to convert the expression to Arcade so I can retain the same labeling scheme when pushing my feature layer ...
1
vote
2answers
176 views

Using Python Parser in ArcGIS Pro Field Calculator?

I am having a problem in migrating from Vbscript to Python for ArcGIS Pro. Building 5, Street 6 What is wrong in this expression? "{}:{}:{}:{}:{}:{}".format("Building ",!Building_Number!," , ",!...
0
votes
1answer
31 views

Simplifying a long if condition statement and adding status report?

def Assign(csdname, cdname, ccsname, zone): if csdname == "Oshawa" or csdname == "Whitby": return "70" elif csdname == "Toronto": return "71a" elif csdname == "Mississauga" or csdname == "...
1
vote
0answers
60 views

If Then Statement, Python Label expression, ArcGIS Pro

I'm trying to create a Python label expression in ArcGIS Pro for a parcel layer where I only want to label the parcel when a street number in the Address field is present.If a street number is not ...
1
vote
0answers
36 views

Field calculator returning ERROR 000989? [closed]

I'm trying to split a field of street addresses (field name "PROP_STREE") so that it returns only the house number (so "123 Main St" would become "123"). Following the solution provided Field ...
0
votes
0answers
89 views

Changing date format for labels in ArcGis Pro with label expression?

I am trying to use an expression to convert my date field to a simple %d,%b,%Y format. Right now it is in "%Y%m%d %H:%M:%S %z" How do I do it properly using Python to do this in ArcGIS Pro? Q&...
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 ...
0
votes
2answers
42 views

Reclassifying vector polygons based on text string to integer using Python Parser of ArcGIS Field Calculator?

So I am trying to reclassify a text string by searching for bits of strings and converting those strings to an integer value in a new field within the field calculator. e.g. I want to find all values ...
0
votes
0answers
44 views

Calculating field after arcpy.Append_management()?

I have some AutoCAD layers (f.e. Cad1, Cad2) and I want to export them into feature class in a geodatabase (f.e. feature_class). Also I want to calculate field in "feature_class" for objects from CAD. ...
0
votes
1answer
83 views

Capitalizing and changing font/color in Label Expression using Python Parser of ArcGIS Pro?

Currently Using ArcGIS Pro 2.3.2 and Python. I am currently trying to label Road names, which are all uppercase in the database. I'm unable to edit the database but would like to Capitalize the road ...
0
votes
1answer
44 views

Auto Incrementing Field based on Selection of Records in Feature Class?

I'm attempting to write a script that will add an incremented value to a field based on a selection of records. For example, the script will select the first 300 records in a feature class and then ...
1
vote
1answer
37 views

Calculating field from three conditional statements

I am working on a road dataset and would like to calculate a field(speed) using three conditional statements from two fields: formOfWay: with value, Dual carriageway etc. routeHierarchy: with values ...
6
votes
1answer
91 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 ...
0
votes
4answers
130 views

Copying/replacing first letter in column of attribute table in ArcMap with field calculator and Python Parser? [closed]

How to copy / replace the first letter in a column if that letter is "N" and replace with "C" in the field name "DISTRICT" inside the attribute table in ArcMap using Python inside the field calculator?...
0
votes
1answer
52 views

Python Script is repeating results

I have developed a python script to copy and paste in the field calculator. Having an input of three values, it compares all of them and returns a list of unique values. The problem is that when I use ...
0
votes
0answers
20 views

Sum calculation in Field Calculator using Python script [duplicate]

I have a problem with Python script in Field Calculator. How to sum the values of one field ('AB') and paste the sum in another field ('RE') using Python in Field Calculator? I'm working in ArcMap 10....
1
vote
2answers
52 views

Use a python expression in Field Calculator to sum each row across several columns

this seems like it should be easy but I am new to python and am having trouble... I have four columns. I would like perform a field calculation that sums the values by row for three of the columns and ...
1
vote
1answer
55 views

Getting angle of point generated from DEM in Raster using Field Calculator in ArcGIS Desktop?

I am trying to calculate the angle of some specific points generated from flow direction in ArcMap 10.2. I converted the DEM to flow direction and then to points. I am trying to convert the grid_code ...
1
vote
1answer
89 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 ...
0
votes
2answers
39 views

Splitting string ID code into various parts

I have a series of identification codes that I need to split out. The format of these codes is [region(letter)][district(number)] - [place(number)][subdistrict(letter)]. An example of some codes ...
0
votes
1answer
275 views

“No module named numpy” Python Error in ArcGIS Label Expression?

I have developed code to label points that pull formatting from a dictionary. I developed this code and it was working fine two weeks ago, today I try to open my map and I am now met with an error ...
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 ...
2
votes
1answer
21 views

Modify script so only empty fields are changed in ArcGIS Pro?

I currently use a script that converts the integer in OBJECTID to a string and combines it with another string (in this case UAW,) to populate a field Field = str(!OBJECTID!) + "UAW" Now that I have ...
0
votes
0answers
413 views

Converting Text Field to Numeric in ArcGIS Pro?

I'm trying to convert text to numeric, but am unable to in ArcGIS Pro. Is there a Python function? I tried int(!FieldName!) but I think NULL values are messing it up?