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 ...
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 ...
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.
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 ...
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:
...
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, ...
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 ...
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 ...
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 ...
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 ...
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.
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, ...
4
votes
Python script in ArcMap Field Calculator giving Error 000539: SyntaxError: Invalid Syntax?
You are missing two )) at the end
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 ...
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:
...
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 ...
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 ...
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 ...
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.
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 ...
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 ...
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, ...
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....
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}'....
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 ...
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:
...
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.)
...
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,...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
error-000539 × 134arcgis-desktop × 76
field-calculator × 62
arcpy × 49
raster-calculator × 41
python-parser × 39
modelbuilder × 26
spatial-analyst × 21
arcmap × 20
arcgis-10.0 × 14
arcgis-pro × 14
arcgis-10.3 × 9
arcgis-10.2 × 8
arcgis-10.1 × 5
map-algebra × 5
error-000732 × 4
nameerror × 4
python × 3
raster × 3
file-geodatabase × 3
error-010240 × 3
attribute-table × 2
expression × 2
arcgis-10.4 × 2
arcgis-10.5 × 2