Extract value to point issues

1063
3
Jump to solution
04-12-2012 06:04 AM
DavidBirkigt
New Contributor III
Morning,

I am having trouble with the extract value to point tool. When my code tries to execute the tool, I  am returned the error
"NameError: name ExtractValuesToPoints is not defined"
As this is a python error not, a arcgis error I would assume it is something in my code, but I can not see it.

My inputs are a feature class from a personal geodatabase and a raster dataset from the same PGDB. The output is a shapefile. I have isolated the portion of my program that uses the extract values function (below). I also saw on the help page the tool is not called through arcpy."toolname"

Thanks
David


import arcpy, os, gc from arcpy import env  #The ingut personal geodatabase env.workspace =r"C:\Users\david\Documents\ValidateChristina\Christina.mdb" #An output folder outLocation= r"C:\Users\david\Documents\ValidateChristina\OutLocation"  arcpy.env.overwriteOutput=True  #Loop through the feature datasets in the pgdb for dataset in arcpy.ListDatasets():      #List the point files found in the current dataset     ptList = arcpy.ListFeatureClasses("*","POINT",dataset)      #list the rasters found in the pgdb     rasterList= arcpy.ListRasters()     print rasterList      #loop through each poinf feature class in the list     for pointFC in ptList:          #Extract raster values that correspond with the listed point file         for raster in rasterList:             #perform the extract             ExtractValuesToPoints(pointFC,raster,outLocation+os.sep+"IntermValue.shp")  print "Done"
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor
When my code tries to execute the tool, I  am returned the error
"NameError: name ExtractValuesToPoints is not defined"


You need to specify the toolbox one of two ways.

This is how they do it in help scripting example for ExtractValuesToPoints:
from arcpy.sa import * ... ExtractValuesToPoints(...)


Or you can skip the from/import and do it this way:

arcpy.sa.ExtractValuesToPoints(...)



The old toolbox alias suffix syntax ("_sa") from Arc 9 arcgisscripting is not supported in arcpy for Spatial Analyst tools. (This change was to support these tools using the new pythonic Map Algebra.)

View solution in original post

0 Kudos
3 Replies
curtvprice
MVP Esteemed Contributor
When my code tries to execute the tool, I  am returned the error
"NameError: name ExtractValuesToPoints is not defined"


You need to specify the toolbox one of two ways.

This is how they do it in help scripting example for ExtractValuesToPoints:
from arcpy.sa import * ... ExtractValuesToPoints(...)


Or you can skip the from/import and do it this way:

arcpy.sa.ExtractValuesToPoints(...)



The old toolbox alias suffix syntax ("_sa") from Arc 9 arcgisscripting is not supported in arcpy for Spatial Analyst tools. (This change was to support these tools using the new pythonic Map Algebra.)
0 Kudos
DavidBirkigt
New Contributor III
Thanks,

I missed that in the help thread (probably stared at it for too long)

Perfect answer
David
0 Kudos
curtvprice
MVP Esteemed Contributor
Perfect answer.


Well, thank you. I want to add that one of the really nice advantages of arcpy is it allows use of intellisense using your IDE or the ArcMap python command line to easily solve these kinds of problems at "coding-time" instead of "run-time".

I still have to use arcgisscripting to maintain script tools that support 9.x and 10.x and I really miss the intellisense there!
0 Kudos