PointDensity Tool will not run in script in v10

618
6
05-13-2011 11:22 AM
DougBrowning
MVP Esteemed Contributor
So i am updating a python script i wrote in 9.3 to v10.  For some reason it keeps giving me a 582 error - which means the parameters are not valid.  The parameters did change a lot in v10 (why I do not know) including not taking the output raster name as a parameter (weird).

So I made the appropriate changes with no luck.  I even took out ALL parameters but the two required ones and it still will not run.  I have tried everything.  It is not a extension problem as I tested that and it gives a different error.  i already tried _sa, etc with no luck.

here is the simplified call

import arcpy, sys, os
from arcpy.sa import *

arcpy.Merge_management(fileList, mergeName)

# Check out ArcGIS Spatial Analyst extension license - need for v10
arcpy.CheckOutExtension("Spatial")
print "here1"

# Run density tool with given params
print "here2"
myNbrCircle = NbrCircle(int(radiusSize), "MAP")
print "here25"
tmpRast = PointDensity(mergeName, "NONE")
print "here3"

It prints here25 but not here3.  i know in other scripts it was an issue with having to use make feature layer first for some reason but I tried that with no luck.  I dont have that script to check the exact steps.  there is nothing in the help about feature layer versus feature class which was the issue before.  Esri sure likes the word feature.

Any help is appreciated.  I just want get it to run simple then I will add in the new Nbr and such.

This is the 9.3 call that worked just fine
gp.PointDensity_sa(mergeName, "NONE", rasterName, int(cellSize), "Circle " + str(radiusSize) + " Map", "ACRES")
Tags (2)
0 Kudos
6 Replies
CathyWilford
New Contributor
Have you tried

tmpRast = gp.PointDensity_sa(mergeName, "NONE")
0 Kudos
curtvprice
MVP Esteemed Contributor
  The parameters did change a lot in v10 (why I do not know) including not taking the output raster name as a parameter (weird).


The parameters have changed a lot to support the new map algebra approach which is fully integrated with Python. Once you get the hang of it I hope you find it is worth it. This is all well-discussed in the What's New in Spatial Analyst help.

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/What_s_new_in_ArcGIS_Spatial_Analyst/0...

I think your syntax issue may be because you are specifying a string (path) instead of the expected raster object. Here's how you convert your path into a raster object in the new pythonized Map Algebra:

tmpRast = PointDensity(Raster(mergeName), "NONE")

Hope this helps!
0 Kudos
DougBrowning
MVP Esteemed Contributor
The PointDensity tools takes a feature layer in not a raster - a raster is the output.  So not sure what you are saying here.  This same error came up with the join tool so i had to use a MakeFeatureLayer first then it worked.  But for PointDensity it did not work.  I have spent 8+ hours on this trying all kinds of paths, different test files, hardcoding everything, a geodatabase, you name it.  It just keeps giving the 582 data type error.  I dont know what it wants.  I can run it on the same files in arcmap using the point density tool directly but in script it dies on those exact same files.

I have no idea what else to try.
0 Kudos
DougBrowning
MVP Esteemed Contributor
Ok i just tried and i can run a simple script with PointDensity in PythonWin itself.

import arcpy
arcpy.CheckOutExtension("Spatial")
print "here25"
tmpRast = arcpy.sa.PointDensity("C:/temp/test2.shp","NONE")
print "here3"

But when I try to call this simple script from ArcMap in a toolbox it does not work.  So there is something wrong with using PointDensity in a script called from a toolbox I guess??
0 Kudos
DougBrowning
MVP Esteemed Contributor
I found it!!

Ok I had to check the box in the tool "Run Python script in process" or it will not work.  I wanted the command window to show so the user could see error messages.  But I guess you can't do that.  Wow that took a long time to find.  I call this a BUG!
0 Kudos
NilsBabel
Occasional Contributor II
Did you ever report this as a bug?  I think I'm having similar issues, except I have to run the script out of process because I'm using Multiprocessing.  The tool crashes on Reclassify.  The statement works when I run it in process but not out of process.  I think it has something to do with the spatial analyst, raster objects, and temporary rasters. Have you learned anything else about this?
0 Kudos