Questions tagged [python-parser]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
943 views

ERROR 000539: Invalid Field !FULLNAME

I am very new to Python and my first attempt hasn't gone too well. I'm trying to overwrite a field that is a spatial join of a couple of features in order to, in the end, generate a beginning and ...
0
votes
1answer
41 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 ...
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?
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". ...
1
vote
1answer
91 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
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 ...
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
38 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
172 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 ...
0
votes
1answer
381 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&...
3
votes
2answers
137 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
74 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
3answers
140 views

Choosing first letters of words in attribute table using Python Parser of ArcMap Field Calculator

I want to write a Python script in Field Calculator which can pick up or choose the fist letters of words and put them in a new field. For example: Lepidium catapycnon..........> Lc Gold blossom ...
0
votes
3answers
6k views

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

I am trying to calculate field test2 with only the numeric values from a string field test. The entire script is like: def makestr(test) list=[] for s in test: if s.isdigit(): ...
1
vote
1answer
62 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 ...
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 ...
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
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
16 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 ...
3
votes
2answers
2k views

Field Calculator: Split address into house number, street name

I have an ADDRESS field in a table with values like: 1 MAIN ST 20 SIDE AVE W 300 JOHN DOE JR RD S I want to use the field calculator to split the addresses and insert the parts into HOUSE_NUMBER and ...
1
vote
1answer
359 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
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, ...
1
vote
1answer
192 views

How to translate VBScript to Python-parser in Field Calculator

How do I translate the following VBScript code in Label Expression to Python using the Python-parser? Function FindLabel ( [MHUNIT], [BLDG_NUM] ) If Not IsNull( [MHUNIT] ) Then FindLabel = [MHUNIT] ...
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
39 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 ...
0
votes
2answers
411 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
42 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 ==...
0
votes
2answers
75 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
81 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 ...
2
votes
1answer
108 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 ...
3
votes
1answer
2k views

Inserting substring in ArcGIS Field Calculator

I'm trying to use the split tool in ArcGIS to add an underscore. Trying to make "ABC11111" look like "ABC_11111". Don't have much experience using Python or VB Script but this is what I have created ...
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/...
4
votes
1answer
41 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
22 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 ...
1
vote
1answer
163 views

Error updating firstChild.data when updating WebCapabilities

I'm trying to update the WebCapabilties to allow uploads for a service definition. I've followed the instructions from ESRI's website, but when I try to set the keyValue.nextSibling.firstChild.data ...
-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 ...
1
vote
2answers
47 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
0answers
68 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
123 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
24 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
271 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
68 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
2 3 4 5
12