1

I have data with multiple columns as 1996_1, 1997_1, etc. I need to perform IDW for each column values and save it. I am a beginner with arcpy. Please help! The code is as follows:

import arcpy, os

from arcpy import env

from arcpy.sa import *

arcpy.env.parallelProcessingFactor = "100%"

arcpy.env.overwriteOutput = True

env.workspace = "F:\Python\Arcpy"

inPointFeatures = "F:\Python\Arcpy\fluctpnt_UTM.shp"

zfield = ["1996_1","1997_1"]

for z in zfield:

    outIDW_1 = Idw(inPointFeatures, zfield,0.002298707671,2,RadiusVariable(10,15000))
    outIDW_1.save("004_{}.tif".format(z))

but i get this error as follows:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\sa\Functions.py", line 2632, in Idw
    in_barrier_polyline_features)
  File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\sa\Utils.py", line 53, in swapper
    result = wrapper(*args, **kwargs)
  File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\sa\Functions.py", line 2624, in Wrapper
    in_barrier_polyline_features)
  File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool

Refer_data

  • @umbe1987 Thank you for answering my question. The script is still not working by replacing z. ExecuteError: Failed to execute. Parameters are not valid. ERROR 000865: Input point features: F:\Python\Arcpyluctpnt_UTM.shp does not exist. ERROR 001000: Z value field: Field 1996_1 does not exist Failed to execute (Idw). – Parimita Saikia Oct 4 '19 at 11:05
  • You should add comments below my answer in order to let me know it, otherwise I could not be notified when you're writing. Anyway, your errors seem to point that you have defined your path to your shapefile the wrong way. F:\Python\Arcpyluctpnt_UTM.shp should be F:\Python\Arcpy\fluctpnt_UTM.shp. tyr changing your inPointFeatures variable like so: inPointFeatures = r"F:\Python\Arcpy\fluctpnt_UTM.shp" (I put an "r" in front of the path) – umbe1987 Oct 8 '19 at 10:15
1

I guess the problem might be that these lines:

for z in zfield:

    outIDW_1 = Idw(inPointFeatures, zfield,0.002298707671,2,RadiusVariable(10,15000))
    outIDW_1.save("004_{}.tif".format(z))

should look like these lines:

for z in zfield:

    outIDW_1 = Idw(inPointFeatures, z,0.002298707671,2,RadiusVariable(10,15000))
    outIDW_1.save("004_{}.tif".format(z))

You need to replace variable z_field with z within your loop, otherwise you are using a list of field names (["1996_1","1997_1"]) as input to the IDW z_field parameter.

Also, I would change the name of your output raster to avoid numbers at first place, as suggested in the Output raster formats and names:

It is generally recommended that you have the first letter of a raster name be a character instead of a number or symbol.

|improve this answer|||||

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.