I have a table with precipitation data from 5 weather stations and I am trying to iterate through the table to perform IDW on each field (month of precipitation).
import arcpy
from arcpy import env
arcpy.CheckOutExtension("GeoStats")
env.workspace = "C:\Users\Lab R220\Desktop\Riley"
arcpy.env.extent = "Thames_watershed.shp"
fieldList = arcpy.ListFields("stationswithprecip.shp")
for field in fieldList:
try:
outraster = str(field.name) + ".tiff"
arcpy.IDW_ga("stationswithprecip.shp", field.name, outraster, 1, 2)
except:
print arcpy.GetMessages()
pass
The error I am receiving are as follows:
Executing: IDW "C:\Users\Lab R220\Desktop\Riley\stationswithprecip.shp" id id.tiff "C:\Users\Lab R220\Desktop\Riley\1" 2 2 "NBRTYPE=Standard S_MAJOR=25461.6476799568 S_MINOR=25461.6476799568 ANGLE=0 NBR_MAX=15 NBR_MIN=10 SECTOR_TYPE=ONE_SECTOR" # Start Time: Mon Jul 22 09:36:46 2019 Failed to execute. Parameters are not valid. ERROR 000361: The name starts with an invalid character
However if I run the months through the IDW tool individually they work. I have 120 of these so I would rather not run them one by one.
My field names look like this with the numbers increasing by 1 "Jan2008" and they are all double
precip
ones? You can use a wildcard in thearcpy.ListFields()
to limit the returned fields and get just the ones that start withprecip
. It looks like it is taking all the fields, including SHAPE and OBJECTID. – Marcelo Villa-Piñeros Jul 22 '19 at 13:59