The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [python-parser]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
318 views

How to concatenate time and date field into one field using ArcGIS for Desktop Field Calculator or Python?

I have two fields, one is ISSUEDDATE and the other is ISSUEDTIME. I would like to concatenate fields so that the ISSUEDDATE is in m/dd/yyyy hh:mm:ss format. My ISSUEDTIME field is a string and ...
0
votes
1answer
518 views

Replacing values in one field with values from another using ArcGIS Pro Calculate Field tool?

I am in the infancy stage with python and have no idea where to start. I simply want to replace values in a field from a feature layer with the values in a field from a table I joined (to the feature ...
1
vote
1answer
265 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
930 views

Calculating the log(10) of a field in ArcMap using the field calculator

I am trying to take the logarithmic function of a field in ArcMap 10.2 using the field calculator in my attribute table. I can't seem to find any equation that does this and the Help document did not ...
1
vote
1answer
161 views

Field Calculator Expression Assistance - Return Value Based on a Text String in Another Field

I'm still in my infancy learning Python (also using arcpy), and I've got a field calculator expression that I am having trouble formatting. Hoping someone can help... I am using ArcMap 10.5. I am ...
0
votes
1answer
310 views

ArcMap Python script for attribute split, replace and concatenate [closed]

I have a problem with attribute table which I'd like to learn to solve without MS Excel. The Shapefile I have, has an attribute field, which consists of 3 parts, separated by ";" -sign. Here is an ...
0
votes
1answer
399 views

ArcGIS field calculator Python generate random point names from attribute table

I am new to arcpy and am looking to generate 15 random point values, which are names from an existing attribute column into a new column. I must use Python in the field calculator. My existing column ...
0
votes
0answers
55 views

python syntax error in field calculator [duplicate]

I'm trying to strip the last character in a string if when the string is split by spaces the last element has a length of 1. I then want to put that letter in front of the rest of the other elements. ...
0
votes
1answer
302 views

model builder expressions code block and definitions

I am having difficulty wrapping my brain around the point of the expression vs the code block. What am I suppose to be defining? I copied the example from calculate value in the ArcGIS help website ...
1
vote
1answer
735 views

Field Calculator: Round UP to the nearest thousand

I have a cost field in a table that I do field calculations on. The field contains values like: 1,000 2,100.00 3,500.99 4,900 I would like to use the field calculator to round the values up to the ...
2
votes
2answers
171 views

Getting only time from Python parser of ArcGIS Field Calculator?

Using ArcGIS 10.4, how I can modify the Date() functions on VB or Python scripts of field Calculator Now ( ) datetime.datetime.now( ) to get only time like 12:32
0
votes
0answers
16 views

ArcGIS Field Calculator reformat Lat Long values [duplicate]

I have a table which is filled with point values that have been exported from an external source. Unfortunately the Lat Long values are formatted strangely and this is preventing me from simply ...
2
votes
1answer
523 views

Use Python in ArcGIS Field Calculator to return value based on numeric value in any of three other fields

I am trying to calculate a new field in ArcGIS 10.5 Desktop using the field calculator, based on the value in any or all of three other fields in the same table. I have not used Python for a while, ...
1
vote
1answer
95 views

Python in field calculator parsing error

I'm trying to perform a selection in an attribute table based on two columns. The intital step I'm intending to perform is to select fields between values, e.g. (a > 0 and a < 10) and from this ...
0
votes
1answer
71 views

Field Calculator: Simple Python If-then and maths

I want to take all positive values in a field and multiply them by -1000. To do this, I put together the following code block: def myCalc(x): if (x > 0): x*(-1000) return x else: ...
2
votes
2answers
50 views

Trouble with if loop in Field Calculator

I'm trying to calculate a field using Python with field calculator but am running into a syntax error. I'm hoping someone can point out what the error is, and I can't seem to figure it out. Below is ...
1
vote
2answers
52 views

Field Calculator Arc Map 10.2

I'm learning as I go , I can't figure out the correct script. I have data in a column named Full_Name which has 3 words ex: Arnault Branch Rd and I want to break it out to StreetName column to be ...
0
votes
1answer
56 views

Field Calculator: Prefixed, padded IDs from a number field

Using the Field Calculator, I want to create prefixed, padded IDs from an existing number field. By "padded", I mean I want the IDs to have a specific number of characters, regardless of how many ...
3
votes
1answer
689 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 ...
2
votes
1answer
54 views

How to Modify and Combine rows in an attribute table?

I would like to modify this attribute table. This is an example First arrange column “ORG_FID” in ascending order If the number of rows corresponding to the column “block Number” is same as well as “...
1
vote
1answer
186 views

Field calculator expression

I am trying to reclassify my vector layer but I seem to have a mistake in my Code Block. The following is an example of what i want; Old values: 10000 20000, 163000 230000 t/m 270000, 30000, ...
1
vote
1answer
131 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 ...
3
votes
3answers
2k views

Concatenating strings from two fields using Python in ArcMap Field Calculator?

I'm new to Python scripting and I don't understand what is wrong with this code. I want to concatenate the string values from GRID1MIL and GRID100K. I've created a text column MGRS to begin with. I ...
0
votes
3answers
373 views

Sequential IDs with field calculator: Pad a prefixed field to specific length

I have an ID field that is a text datatype. The IDs in the field have a prefix, and are padded with zeros to always be a specific length. Examples: INSP000098 INSP000099 INSP000100 INSP000101 I ...
0
votes
1answer
93 views

ArcMap Python Maplex labeling

I'm doing Maplex-Python labels for municipality polys with yields positive, zeroes and null values. I want to label all municipality polys by their municipality name, however I don't want to display ...
3
votes
1answer
73 views

Understanding ArcGIS field calculator behaviour with geometries?

In Getting Properties of Next Record Using Calculate Field Tool in ModelBuilder? the OP asks for suggestion on calculation of distances between pairs of points in a feature class. I thought of ...
0
votes
1answer
160 views

Parsing Data for Label using Python

I have field called PIN in my parcels shapefile. Formatting looks like this: xx-yy-zzzzz, just much longer. I want to split the first two sections on one line and the third (the z's) on the next. I ...
2
votes
1answer
294 views

Python in ModelBuilder calculate field tool

Code works on ArcMap "Field Calculator..." when I click on attribute and calculate. But if does not work in ModelBuilder calculate field tool. Any ideas? Pre-Logic Script Code: def ifBlock(...
2
votes
2answers
53 views

Using field calculator to find the next nearest (next minimum value)

I'm new to Python, but I'm attempting to find the next smallest value in a field, using another field as a case field (within field calculator in ModelBuilder). I've drafted the following, but it does ...
3
votes
1answer
53 views

Getting Properties of Next Record Using Calculate Field Tool in ModelBuilder?

I'm trying to calculate the distance between the centroids of adjacent records (adjacent in the attribute table, not necessarily in space) into an attribute field. I'm planning on using the ...
1
vote
3answers
151 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
4answers
591 views

Using Field Calculator with .replace?

I'm using the Field Calculator .replace function to replace WEST, EAST, NORTH, SOUTH to W, E, N and S and I'm using 4 scripts !PREDIR!.replace("WEST*","W") and so forth. I would like to use one ...
1
vote
1answer
29 views

Sort User Defined Features Classes Into Premade Feature Dataset Using ModelBuilder?

I have a large Model where the user selects the text file, it creates the xy file, then decimates the file, thus creating a feature class. I would like this decimated feature class to get sorted ...
1
vote
2answers
736 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" (...
0
votes
1answer
419 views

Editing buffers in Arcmap 10.3

Working for an environmental agency, they ask me to edit in ArcGIS the sizes of the buffers for the same layer. Is that possible to change it using python in the field calculator? If yes, I seek ...
0
votes
2answers
289 views

Error 000989 Python Syntax error in Field Caclulator

Using ArcMap 10.4 here and having some trouble running some python code in the field calculator. I am trying to populate one text field based on the value of another text field. Here is what I am ...
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
36 views

Arcgis Label Expression based Value

I am trying to make election map so I can draw chart and label with same chart color. So I have six election zone and running candidates may be up-to six or less. So if some election zone might have ...
1
vote
1answer
124 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 ...
2
votes
2answers
45 views

Merging Fields into new field using python and eliminating space in before and after the field using field calculator

Am interested in combining ClASS1 and SUBCLASS1 to form the one combined class. I wrote the expression as follows "() ()" format( !CLASS1!replace(" "","" ),( !SUBCLASS1!replace(" "","" ))as shown in ...
2
votes
1answer
180 views

Using Simple Python Parser expression?

My level is very basic in Python. This is the python codeblock I have in ArcGIS Field Calculator: def Reclass(THLB): if THLB == 0: return 0 elif THLB == 1: return !Shape_Area! This ...
1
vote
0answers
38 views

Limit the number of lines in a stacked label using python parser in ArcMap labels

I am labeling names of places by stacking the labels at each space using the python code below. This makes some incoherent labels for text with many spaces and short or abbreviated words. def ...
2
votes
2answers
333 views

Use field calculator to return the word after “unit”?

Working on ArcMap Desktop 10.5; the file in question lives in a file gdb. I have a polygon layer with a field of full property addresses (string) from which I need to extract ONLY the unit number, to ...
3
votes
1answer
897 views

Python Max Function in Field Calculator for Date values

I have 4 fields with Date Time values, and created a new field (Date type as well) which takes the most recent date from these 4 fields. I have tried using the Max python in the field calculator to ...
1
vote
1answer
95 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 ...
1
vote
1answer
315 views

Remove first character from a string if it satisfies an if statement [closed]

I have a bunch of phone numbers and some contain a 1 in front of them e.g. "18885556607" and I would like to simply remove the 1. I can't just remove all first characters because there are numbers ...
0
votes
1answer
53 views

Populate field using a combination matrix

I have a polygon shapefile that represents combinations of soil hydrologic type (A,B,C,D) and soil cover (53 different possible covers, coded from 0 to 53). Each of the 53 soil covers can be either ...
2
votes
2answers
215 views

ArcMap Field Calculator Python string concatenation malfunction

I am trying to concatenate three fields into one using Python with the rjust padding function. My function in the code box is the following: def AutoSchluessel(gmk, zae, nen): return "{}0{}{}"...
2
votes
2answers
700 views

If/Then Statement Label Expression

I have done a lot of research and cannot seem to get the following expression right. I have three (3) attribute columns - ID, Diameter, and Material, I would like to label sewer lines with the unique ...
0
votes
1answer
176 views

Calculating a field error

I have this table: And I want to create a field called "COSN2" which after the creation I want to fill it with three characters from the field "COS207". Than I wrote the following script: import ...