Working with ExtractMultiValuesToPoints in python

1379
1
08-12-2011 08:06 AM
AllWeatherHeather
Occasional Contributor
I am trying to incorporate ExtractMultiValuesToPoints tool into a workflow I am automating. I would like to have the script build the input parameters dynamically so that I can work with any number of raster inputs.

The resulting inRasterList variable I have created looks like this:
[["elev_gridElev_L1.tif", "elev_gridElev_L1"], ["elev_gridElev_L2.tif", "elev_gridElev_L2"], ["elev_gridElev_L3.tif", "elev_gridElev_L3"], ["elev_gridElev_L4.tif", "elev_gridElev_L4"]]

When I copy and paste this string into the tool call it performs as expected:
ExtractMultiValuesToPoints(pointFile, [["elev_gridElev_L1.tif", "elev_gridElev_L1"], ["elev_gridElev_L2.tif", "elev_gridElev_L2"], ["elev_gridElev_L3.tif", "elev_gridElev_L3"], ["elev_gridElev_L4.tif", "elev_gridElev_L4"]], "NONE")

If I replace the inRasterList with a variable name it fails with the following error:
inRasterList = [["elev_gridElev_L1.tif", "elev_gridElev_L1"], ["elev_gridElev_L2.tif", "elev_gridElev_L2"], ["elev_gridElev_L3.tif", "elev_gridElev_L3"], ["elev_gridElev_L4.tif", "elev_gridElev_L4"]]

ExtractMultiValuesToPoints(pointFile, inRasterList, "NONE")

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000859: The required parameter Input rasters is empty, or is not the type of Extract Values.

If anyone recognizes this problem or has any suggestions it would be greatly appreciated. If I can't solve this I will have to abandon the use of this tool in my final product.
0 Kudos
1 Reply
AllWeatherHeather
Occasional Contributor
Ahhh, I figured it out!

You need to create a "Value list" as the raster input.

inRasterList = arcpy.ValueTable(2)

then in a loop add the rasters you are interested in:

inRasterList.addRow(var1 + var2)
0 Kudos