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
41 views

Calculating mean value with field calculator for selected records using ArcPy

I want to calculate the mean value in the field z which has Type Zero and write it in Ground field. How can I do that with arcpy? arcpy.MakeFeatureLayer_management(Shapefile, "layer") ...
0
votes
2answers
54 views

ArcGIS Pro Python Field Calculating

I am trying to use Python in ArcGIS Pro to cleanse some data via imported Excel sheets. The expression works, but the Code Block if-else statement to return nothing if !Street_Id! is returns an error....
0
votes
1answer
51 views

Split in ArcGIS 10.8

Working on ArcMap Desktop 10.8; I have a point layer with a field called SITEROAD (string) from which I need to extract ONLY the first word before a space, and put it into a new field, STREETNAME. ...
-1
votes
1answer
42 views

Extracting numbers from string using field calculator of ArcMap [closed]

I need to move number values one field to another field in ArcMap. There's no need to move any alphabetic string vales. Like attached picture shown having number values too so I want those number ...
0
votes
1answer
25 views

ArcMap 10.7 Python Label Expression - compound. expression verified but will not label. Syntax issues

I have road ID labels in a string field that need to be parsed down. I'm using the python advanced label expression. I've removed the preceding '0s' successfully as well as some known text. I need to ...
1
vote
1answer
33 views

Writing Field Calculator codeblock using Python parser of ArcGIS Pro

The following code isn't working as expected and I'm not sure why: UpOrDown = reclass(!UpOrDown!) def reclass (Z,GP): if (GP == "DT" and Z == "CG"): UpOrDown = 1 if (GP == "DT" and Z ==...
2
votes
1answer
59 views

Writing If-Then Statement in ArcGIS Pro Field Calculator Code Block using Python Parser

I have two columns in my shape file with text values called GP and Z which contain abbreviations and a third column called UpOrDown which is meant to hold the binary 0-1 generated from the if-then ...
1
vote
1answer
55 views

Why does Python if/else statement only return else condition when trying to reclassify field using ArcMap field calculator?

Using arcgis v 10.4. I'm trying to reclassify values from a field (ECOREGION_DIVISION), which is in string format, into new values using the following Python syntax: def Reclass(ECOREGION_DIVISION): ...
0
votes
0answers
31 views

Field calculator - “and” + “or” operators not working in “If/Then” statement

The following Python code I'm trying to use isn't working, and I believe it's due to how I've integrated the "and" and "or" operators. Although I suspect my full code (below) is not ideally written/...
3
votes
1answer
29 views

Field calculator 'if/then' statement, with 'and' not working

I'm trying to do some conditional formatting of an attribute table using Field Calculator. I tried using code below, but am not getting any returns that meet conditions specified (even though the ...
1
vote
1answer
17 views

Using Python to label points with format dependent on date of measurement in ArcMap

I have a database of wells and water level measurements which I would like to label in a stacked manner with the ID on top and the measurement below it. If the measurement is from 2020, it should ...
0
votes
1answer
36 views

Implementing ArcPy codeblocks

I have tried examples from the GIS support website and many more, but I cannot figure out how to get a codeblock for a field calculation to work within ArcPy. Part of my code is underneath, it is a ...
0
votes
1answer
18 views

Calculating Field in ArcGIS Pro ModelBuilder

Trying to setup my first automated mapping project and I need to add a field and then set it to 0. I've tried to use the Calculate Value tool, but I don't have any idea how to actually use this as it ...
-1
votes
1answer
42 views

Extracting specific words from the list of attributes and return all the possible words to a new field with the help of defined dictionaries

I need to extract specific words from the list of attributes and return all the possible words to a new field with the help of defined dictionaries. (using Python Parser in ArcGIS) Example Apples ...
0
votes
0answers
30 views

Polsby-Popper measure in field calculator of ArcGIS Pro

I'm trying to assess the compactness of Virginia's congressional districts using the Polsby-Popper measure (4π (Area/Perimeter^2)), with this being my input into the code block: import math def ...
1
vote
1answer
74 views

ERROR 000539: NameError: name 'prevX' is not defined

I'm trying to use the field calculator to input data into a field that I previously created, but it keeps saying that prevX is not defined in line 9. I'm very new to python and I don't really ...
1
vote
2answers
48 views

Combining two simple scripts into single script in Python Parser of Field Calculator

I have two separate scripts used in Field Calculator for an "ID" attribute field. Script 1 is to create sequential numbers for the field. Script 2 is to add leading zeros to the sequential numbers. ...
0
votes
1answer
20 views

Adding Thirty years to date field using ArcGIS Pro Field Calculator

I have 2 fields one is Creation Date the other is Maintenance Date. The Maintenance Date should be 30 years after the Creation date. I have been trying to use the field calculator for this. But I ...
3
votes
1answer
41 views

Field calculate sequential values, but assign same number to duplicates

I work at a company where I have to constantly update parcel maps and generate tables representing landowner parcels. I have figured out how to sort the landowner name field in the table ...
2
votes
2answers
153 views

Modifying label string using Python label expression

I'm attempting to modify my feature labels such that the "NB", "SB", "WB", and "EB" portion of the string is removed: E.g. "CEDAR AVE NB" --> "CEDAR AVE" or "ROBERT TRL S SB" --> "ROBERT TRL S" The ...
0
votes
1answer
41 views

Calculating median in grouped data using ArcMap [closed]

I got stuck when calculating the median age in grouped data (age ranges) for each feature (each feature is a single administrative unit). I have about 18,000 features. Field names indicate age ranges:...
1
vote
1answer
34 views

Conditional statement using Long and Text fields with Python Parser of Calculate Field in ArcGIS Pro

I have 3 fields: "ISL_Numero" - Long (values are '1', '2', '3', '4' etc.) "Subtipo_IS" - Text (values are 'A', 'B', 'C' etc.) "Ambiente_C" - Text (values I want to ...
0
votes
0answers
30 views

Calculating difference between value of each row using ArcMap Field Calculator

Logic: Compute the difference between the angle for each subsequent geometry in the attribute table def GetAngleDif(angle): dif = angle.a - angle.b return dif ERROR 000539: Error running ...
1
vote
2answers
50 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
34 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
19 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
95 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
29 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
20 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
111 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
162 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
34 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
55 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
246 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
869 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
33 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
37 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
88 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
48 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
70 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
62 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
48 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
42 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
50 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
57 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
67 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
35 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
79 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
56 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) = '...
1
vote
2answers
194 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!," , ",!...

1
2 3 4 5
12