Hi,
I am trying to create a series of point shapefiles based on a series of raster datasets. I have set up and run the ExtractValuesToPoints tool in the Model builder (so I know the process works OK). I then exported the script to a .py file so I could iterate over all my files using a for loop (code below). When I run I get the following error message:
Traceback (most recent call last):
File "C:\models\ArcRegression\RasterToPoint.py", line 35, in <module>
gp.ExtractValuesToPoints_sa(GridPoints, RasterFile, PointFileOut, "NONE", "VALUE_ONLY")
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000860: Input point features: is not the type of Composite Geodataset, or does not exist.
Failed to execute (ExtractValuesToPoints).
I think this means the geoprocessor is not reading my input parameter as a point shapefile. Having done some googling, I found some information on using GetParameterAsText(), but don't understand how the script will "know" what each parameter is without referring to the GUI box in ArcMAP (which I wan't to avoid as I wish to automate the process).
Any advice gratefully received!
Thanks,
Kate.
Code:
# Import system modules
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
# Check out any necessary licenses
gp.CheckOutExtension("spatial")
# Load required toolboxes...
gp.AddToolbox("C:/Program Files (x86)/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")
# Local variables...
FLocation = "C:\\models\\ArcRegression\\" #location of all files
RasterFiles = ["amph_spprich", "amph_endrich", "bird_endrich", "bird_spprich", "cloudann9__11", "dem9__11", "llnd_gd", "llnd_res", "llnd_sv", "llnd_tv", "mamm_endrich", "mamm_spprich", "meantemp9__11", "mnts_gd", "mnts_res", "mnts_sv", "mnts_tv", "srtoaann", "sumrain9__11"] # Names of all raster files to be converted to points
PointFilesOut = RasterFiles # To give output files same names as inputs
GridPointsName = "9__11grid_1kmPoint" # Name of existing point file (used to extract from rasters)
# Process: Extract Values to Points...
for i in range(0,len(RasterFiles)):
PointFileOut = str(FLocation) + str(PointFilesOut) + ".shp"
RasterFile = str(FLocation) + str(RasterFiles)
GridPoints = str(FLocation) + str(GridPointsName)
print("Working on " + str(RasterFile))
gp.ExtractValuesToPoints_sa(GridPoints, RasterFile, PointFileOut, "NONE", "VALUE_ONLY")