I am trying to run the PointDensity
function on a feature class located in a shapefile:
[edit shp_file_path]
shp_file_path = os.path.join('path_to_shp_folder', 'shp_file_name')
if os.path.isfile(shp_file_path):
out_raster = arcpy.sa.PointDensity(shp_file_path , 'FIELD_NAME', 0.000278832485028573, NbrCircle(2.32360404190478E-03, 'MAP'), 'SQUARE_METERS')
This is a code is pasted from the ArcGIS Pro Desktop application history after it run successfully from the toolbox.
In ArcPy, I get the following error:
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000354: The name contains invalid characters
- I have verified that path_to_shp_file is a valid file path.
- I have checked with various numbers options inside the cellSize, and the NbrCircle.
- I have tried from several locations on disk.
- I have used MakeFeature_managment to create an in-memory feature class and gave its name as an argument to the input feature class.
- I have verified that the workspace path is defined.
- I have verified that the field 'FIELD_NAME' exists in the feature class by opening it in the desktop software.
- I have verified that the feature class contains records of shape 'Point'.
- I have tried to clone a new ArcPy Python virtual environment and configure its interpreter.
- I have verified that I imported NbrCircle correctly.
How can I resolve this error?
Best Answer
It turned out that the path to the wokspace in:
was wrong, and the error message was not that helpful. After I fixed it, the command run successfully.