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.8k
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,373
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.9k
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.2k
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
  • 65.8k
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,706
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
  • 43.4k
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,378
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
  • 72.6k
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.7k
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
  • 65.8k
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
  • 72.6k
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.7k
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

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
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
  • 892
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
  • 65.2k
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,280
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
  • 72.6k
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,835
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
  • 40.9k
3 votes
Accepted

Automating date creation in field calculator

As you can see from the error, it is complaining about line 1. There is no MED in Line 1 of the code block, but there IS a MED in line 1 of some iterations of the expression line. And it's not quoted,...
Son of a Beach's user avatar
3 votes
Accepted

Use Calculate Field GP tool to update feature coordinates

Solved: For an unknown reason, for part in geometry: and for point in part: don't seem to work in the Field Calculator. But if we replace for part in geometry: with: for i in range(geom.partCount): ...
User1974's user avatar
  • 1,132
2 votes

Meaning of ERROR 000539: Error running expression: rcexec() <type 'exceptions.ImportError'>: No module named os?

This error is discussed in an Esri Technical Article entitled Error: ERROR 000539: Error running expression: rcexec() which says: This error is due to Raster Calculator not being exposed to Python ...
PolyGeo's user avatar
  • 65.2k
2 votes
Accepted

Implementing output file extension considering type of workspace in ModelBuilder?

Consider testing against the workspace type property. In your calculate value tool (you only need one for this step), modify your code to look something like this: import os, arcpy def ...
Nxaunxau's user avatar
  • 3,923
2 votes

ArcGIS Field Editor if/else syntax with python

In the code block window of the field calculator, try using: def new(DB_Low): if DB_Low == 0: return 0 else: return DB_Low + 2.25 And then in the expression window: new(!...
Joseph's user avatar
  • 75.8k

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