Hi, I'm Vinay.M.,
A Scholar of GIS from University of Mysore, India
I'm trying to build ArcPy Code, to Interpolate(IDW) all columns(DAY001, DAY002, and DAY003) in a feature class(Testing.shp) using ListField()
But Failed
import arcpy
import os
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
workspace = r"C:\Users\Admin\Desktop\Python"
env.workspace = workspace
fields = arcpy.ListFields("C:\Users\Admin\Desktop\Python\Testing.shp")
for field in fields:
outIDW = Idw()
outIDW.save(os.path.join(env.workspace,fields+".tif"))
Anyone Please help me
File Attached
I would suggest doing the process manually through ArcToolbox's Spatial Analyst IDW once, then go to the Geoprocessing Results window and copy the code snippet. That will give you the correct format for accessing the required fields. From there, then you can cycle through your field list to perform the IDW. Besides, just getting the field is only one issue, you still have to deal with the desired processing extent, the desired cell size and a variety of other factors that go into an informed IDW interpolation
Let me toss out a little helper on listing the fields. You want to use a wildcard to _only_ get your DAY fields:
arcpy.ListFields(ds, "DAY*")
Also you get a list of field objects, not field names, so you need to do this in your loop:
for field in fields:
fname = field.name
outIDW = Idw(ds, fname ...
outIDW.save(....)