Questions tagged [python-parser]

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

Filter by
Sorted by
Tagged with
2
votes
0answers
28 views

Python label script [closed]

I'm trying to make a label expression using Python (open to using VBscript or Jscript as well) and I just cannot get the result I want... I have 2 columns within my attribute table and I want them ...
1
vote
1answer
15 views

Adding two fields in attribute table and assigning result to third field if some cells contain null values using ArcGIS Pro Field Calculator

I am using ArcGIS Pro, field calculator to add the values of two fields (Result_A and Result_B) and assign the value to new Field Combined_Result. The type for all three fields is "double". ...
6
votes
1answer
100 views

Creating Unique IDs of points in order from west to east

I have a dataset with over 1000s points. I am wondering if I am able to give each point a unique ID starting from west to east. I am using ArcMap 10.6. Is there a way to do this in ArcMap?
0
votes
0answers
44 views

Python conditional statement for range of numbers isn't working

Using ArcGIS desktop 10.7. The field Shape_area_Hect is float and the field Core_patch is string. Error for following syntax: def Reclass(Shape_area_Hect): if (Shape_area_Hect >= 12150): ...
1
vote
1answer
37 views

Re-ordering text strings within field using Python Parser of Field Calculator

At ArcGIS 10.8.1, I have a shapefile attribute table containing a text field with names ordered last, first, middle, as in this example: Smith Sally J Doe John Jones William Randolph ... I need to ...
2
votes
2answers
170 views

Reducing number of if statements in Field Calculator code block of ArcGIS Pro

I am using Python 3 in ArcGIS Pro. In plain English, my goal is calculate one field in a table using a list of values from another field. I can do this with a long list of if statements, but I can't ...
3
votes
2answers
136 views

Expression in arcpy.CalculateField_management

I am working on a toolset, and one of the inputs is a field of a shapefile. I have defined the field and I have used it in multiple functions, and it is working without any error. The problem is that ...
0
votes
2answers
71 views

Extracting numbers and text from string field using Python Parser of ArcMap Field Calculator?

This is a similar question to Extracting numbers from string field using Python Parser of ArcMap Field Calculator? I have a similar issue in ArcMap 10.6. I have a field named 'SIZE' that holds number ...
1
vote
1answer
56 views

Exclude certain values in string field when labelling in ArcGIS Pro [closed]

I am trying to label a field on a map but exclude certain text strings from appearing. Specifically, I am working with pipes and their labels. The string values include the pipe size and material so ...
0
votes
0answers
29 views

Using Python Parser in field calculator to update column from another column

I am an experienced ArcMap user who is fairly new to Python. I am having trouble getting the script to look for a list of values and assign a new label in a new column. The script runs without errors ...
1
vote
3answers
58 views

Using Python if/then codeblock to determine line segment lengths in ArcMap Field Calculator

Can anyone help me create a codeblock using an if/then statement through the Python parser in Field Calculator, to calculate the length of a line segment when the value of a different field is a ...
1
vote
3answers
56 views

ArcPy string concatenation with both forward and back slashes

I am trying to concatenate 2 string variables Var1 and Var2 using python (converting some old ArcGIS VB-based scripts to ArcPy). I need to add a backslash between them. arcpy.CalculateField_management(...
0
votes
0answers
15 views

ArcGIS hyperlink script to assesor maps based on different account numbers

I am adding a hyperlink within the attribution to open up to our local county assessor maps. I am able to get the hyperlink to work directing the user to the map directory to look up based on a given ...
2
votes
2answers
230 views

Python syntax returning only part of the if/elif statement in Field Calculator?

Using ArcGIS 10.7 desktop. I want to reclassify a land use field using Field Calculator. Grasslands are conditionally reclassified using a 'veg_type' field (Avena, or Bromus) and a CWHR land use field ...
0
votes
1answer
26 views

Calculating Min and Max Across fields while skipping Zeros

I am using ArcGIS Desktop 10.5 here. I have a streets layer that has address ranges in the fields FromLeft, ToLeft, FromRight, and ToRight. I am trying to create a street index csv that has the low ...
1
vote
2answers
49 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
1answer
45 views

Field Calculating using Python Parser with Standard SQL Query Layers & Views in ArcGIS Pro

I have been given the task to extract PASER scores from a comprehensive table of of PASER_byYear. I would like to take the time to create a view and query layers using SQL, but do to time constraints, ...
0
votes
2answers
74 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
57 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
77 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
37 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
41 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
102 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
90 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
34 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
38 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
20 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
66 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
40 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
45 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
66 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
118 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
54 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
22 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
47 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
263 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
67 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
36 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 ...
1
vote
2answers
63 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
178 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
34 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
22 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
175 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
352 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
73 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
486 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
2k 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
2 3 4 5
12