As of May 31, 2023, we have updated our Code of Conduct.
11 votes
Accepted

Using ArcPy with ArcGIS Pro and ArcGIS Desktop on same machine?

I'll try to explain this the best I can so hopefully you can move forward. The short answer is, if your PYTHONPATH is pointing at an actual version of Python, when a product loads up and needs Python ...
KHibma's user avatar
  • 16.2k
7 votes
Accepted

Normalizing raster using raster calculator raises TypeError

The builtin python min() and max() functions operate only on python iterables (i.e lists, tuples, etc.) and return the smallest/largest item in the iterable. They do not return the minimum/maximum ...
user2856's user avatar
  • 60k
7 votes
Accepted

If/Then python script in Field Calculator not working

You have a repeated typo: match.fabs instead of math.fabs. math is a python library, fabs is the absolute value function.
J Kelly's user avatar
  • 1,343
7 votes
Accepted

Calculating Polsby-Popper Score Using ArcGIS Pro Field Calculator gives ERROR 000539?

As was mentioned in the comments, your formula should read: (12.56637 * !AREA_GEO!) / (!PERIM_GEO! ** 2) or (12.56637 * !AREA_GEO!) / (!PERIM_GEO! * !PERIM_GEO!) This page on python operators ...
Fezter's user avatar
  • 21.7k
6 votes
Accepted

Correct expression syntax for filling field with string in calculate field in ArcPy?

The problem with your script is the expression. The expression must have the variable in single quotes since it is a string. There are a number of ways to format this. My favorite is as follows: ...
Ben S Nadler's user avatar
  • 1,604
6 votes
Accepted

If-then-else Statements and string errors?

You are only passing one variable into your function: PropType. But on the first line of your function, you refer to a variable named PropClass. Your function has no idea what this variable is, ...
Dan C's user avatar
  • 12.1k
6 votes
Accepted

Calculating NDVI

Start the filename of the output raster with a character not a number, i.e NDVI_1988_1 instead of 1988_NDVI_1 From the Esri FAQ: What characters should not be used in ArcGIS for field names and table ...
user2856's user avatar
  • 60k
5 votes

ArcPy Raster Calculator error " 'str' object has no attribute 'save' "

Per the Esri documentation, this tool is not available in arcpy scripting: http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/raster-calculator.htm Note: The Raster ...
SMiller's user avatar
  • 3,666
5 votes

Use Calculate Field GP tool to update feature coordinates

Some years ago ESRI changed the behaviour of field calculator. In the past you could directly manipulate and update the Shape field as you are attempting within a field calculator. This functionality ...
Hornbydd's user avatar
  • 41.8k
4 votes

Avoiding error 000539 from code block in Calculate Value tool?

You want to reference the outputs of the Check Raster tool in your function definition, not the function name itself. Also from the help: In-line variable of type string should be enclosed within ...
Emil Brundage's user avatar
4 votes
Accepted

Python codeblock to remove numeric characters from a column not working

Your input and output column should be text type. It's expecting a string or buffer and you passed probably integer or double.
dmh126's user avatar
  • 6,542
4 votes
Accepted

ERROR 000539: Error running expression

You are trying to join a List.remove (returned from .split()), but a List.remove doesn't return anything, so you'd have to remove the item from the list and then join, or if you want to do it inline, ...
Dan Jurgella's user avatar
  • 2,358
4 votes

Python script in ArcMap Field Calculator giving Error 000539: SyntaxError: Invalid Syntax?

You are missing two )) at the end
BERA's user avatar
  • 63.8k
4 votes
Accepted

Embedded quotes in arcpy.CalculateField_management expression

As mentioned in my comment above, adding triple quote marks around a string will allow you to use quote marks within the string """ your string that contains additional "double" and 'single' quotes ...
Midavalo's user avatar
  • 29.5k
4 votes
Accepted

CalculateField_management, python Toolbox

In the CalculateField_management you are giving the desc.baseName as the expression parameter. It assumes the value of that variable is the name of a function that is not defined. This should work: ...
Carlos MSF's user avatar
4 votes

Defining a Python function to calculate a value using multiple fields

You need to separate arguments with commas Flow_Indiv= iFlow(!PitotPressure!, !COE!, !HydrantOrificeFlowed!) Code Block def iFlow(PitotPressure, COE, HydrantOrificeFlowed): if ...
user2856's user avatar
  • 60k
4 votes
Accepted

Calculate field in a joined table in ArcPy

Maybe your problem could be the the way you are accessing the table and field names. Try setting Qualified Field Names environment setting. You can try Join Field which should be easier/require less ...
BERA's user avatar
  • 63.8k
3 votes

Replace occasional Space with Underscore using Python parser of ArcGIS Field Calculator?

You don't necessarily have to define a function for this one. Try this: str(!PlaceName!).replace(' ', '') The "not defined" error is related to the lack of quotes around the NoSpace1. This could be ...
crld's user avatar
  • 882
3 votes
Accepted

ERROR 000539: Invalid Field !FULLNAME

The first thing that I would check is whether your feature class has a field called FULLNAME. The error message that you are receiving suggests that it does not.
PolyGeo's user avatar
  • 64.7k
3 votes
Accepted

Why is arcpy.CalculateField_management() writing 1899-12-30 00:00:00 instead of expected date?

The code below demonstrates how to get this to work using code very similar to that in the question, but I recommend also reviewing the detailed explanation that follows in order to understand why it ...
Paul's user avatar
  • 11.6k
3 votes

Entering date with arcpy.GetParameterAsText()?

First, you are getting FC as parameter/variablebut trying to calculate fc (i.e., Python is case sensitive); Second, if you pick "Date only" option from parameter window for date, your script will ...
fatih_dur's user avatar
  • 4,923
3 votes
Accepted

Printing name of field with highest value?

This should work: def compMaxField(table, fields, maxFldName, maxValName): arcpy.AddField_management(table, maxFldName, 'TEXT') # field name with max value arcpy.AddField_management(table, ...
Jan Šimbera's user avatar
  • 1,304
3 votes
Accepted

Python script in ArcMap Field Calculator giving Error 000539: SyntaxError: Invalid Syntax?

You're missing closing parentheses. For complex expressions, you really need to leverage whitespace to help you catch this stuff. Try some indentation: 60 * math.degrees(( math.acos( math....
jpmc26's user avatar
  • 1,709
3 votes
Accepted

Calculating Field Chosen by arcpy.GetParameterAsText(1) gives ERROR 000539?

Try using Python String Formatting to insert your variable into a string. For example, if your field name is SampleField, you could use string formatting in this line arcpy.AddMessage('Campo: {0}'....
Midavalo's user avatar
  • 29.5k
3 votes
Accepted

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

I think you're almost there, but you need to get your indentation consistent. Indentation is very important in Python and defines the scoping/grouping of statements. Suggested indentation is to add ...
cm1's user avatar
  • 2,220
3 votes

Concatenate fields (double and string) to create address using arcpy

You can use the da.UpdateCursor: import arcpy fc = r'C:\data.gdb\featureclass' #Change fields = ['SiteAdress','STNUM','STRDIR','STRNAME','STRTYPE'] with arcpy.da.UpdateCursor(fc,fields) as cursor: ...
BERA's user avatar
  • 63.8k
3 votes
Accepted

NameError: name '**' not defined in ModelBuilder Calculate Value

In this case, in the Calculate Value tool... The 'Code Block' field should be empty The 'Expression' field should be: "%value%"[0:6] (The expression should include the quotation marks.) ...
Son of a Beach's user avatar
3 votes
Accepted

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

You need to define an intial value for prevX (and for prevY) before you use them in a calculation. Otherwise, the first time the code tries to read their value, it fails. This cannot occur on line 6,...
Son of a Beach's user avatar
3 votes
Accepted

Using RasterCalculator in ArcGIS Pro ModelBuilder gives ERROR 000539

What is happening is that the Raster Calculator is trying to subtract one complete raster from another. It believes you have supplied a new raster named "%Value%" which evaluates to a raster ...
JasonInVegas's user avatar
  • 1,745
3 votes
Accepted

Raster Calculator Python Error 00539 for friction surface

When creating raster data in geodatabase, you do not need to add file extension such as .tif. This a mentioned in the help of Create Raster Dataset: When storing a raster dataset in a geodatabase, do ...
ahmadhanb's user avatar
  • 39.6k

Only top scored, non community-wiki answers of a minimum length are eligible