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
env.workspace = "C:\Users\Lab R220\Desktop\Riley"
arcpy.env.extent = "Thames_watershed.shp"
fieldList = arcpy.ListFields("stationswithprecip.shp")

for field in fieldList:
        outraster = str(field.name) + ".tiff"
        arcpy.IDW_ga("stationswithprecip.shp", field.name, outraster, 1, 2)
        print arcpy.GetMessages()

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

  • Do you have any other fields on that shapefile besided the precip ones? You can use a wildcard in the arcpy.ListFields() to limit the returned fields and get just the ones that start with precip. It looks like it is taking all the fields, including SHAPE and OBJECTID. – Marcelo Villa-Piñeros Jul 22 '19 at 13:59
  • Yes I do but I get the error for every single field. I get about 120 of those error messages when I run the code. I figured the OBJECTID wouldn't work so I threw in the except : pass so I could just skip over those columns and on to the next one. – RJAM Jul 22 '19 at 14:16

I found the problem

arcpy.IDW_ga("stationswithprecip.shp", field.name, **""**, outraster, 1, 2)

The problem was in my parameter list. It was naming each file 1 which is supposed to be the cell size. I added the "" and now it works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.