AnsweredAssumed Answered

Iterating Kriging with Anisotropy

Question asked by spenc112 on May 12, 2017
Latest reply on Aug 8, 2017 by spenc112

Hi,

 

I'm trying to write a python script that will run kriging interpolation with anisotropy on 700+ variables in a dataset. I've read a lot already about using the Create Geostatistical Layer tool and was able to code it but cannot get it to automatically iterate through all my fields. It seems like I'd have to manually change the field each time which is just not efficient with the number of columns I have.

 

I've done an iteration before for a simple IDW interpolation using ListFields but it doesn't seem to work with this interpolation method.

 

Can anyone shed some light on this? I've pasted my code below. I'm VERY new to python so I apologize if it's a mess.

 

import os
import arcpy
import arcpy, os
from arcpy import env
from arcpy.sa import *
Sediment1999 = "C:\\Users\\courtney\\Desktop\\MundleStableIsotope\\StableIsotopeData.gdb\\Sediment1999"
arcpy.env.workspace = r"C:\\Users\\courtney\\Desktop\\MundleStableIsotope\\StableIsotopeData.gdb"
arcpy.env.extent = "C:\\Users\\courtney\\Desktop\\MundleStableIsotope\\DetroitRiverBoundary.shp"
arcpy.env.mask = "C:\\Users\\courtney\\Desktop\\MundleStableIsotope\\DetroitRiverBoundary.shp"

 

arcpy.CheckOutExtension("GeoStats")
fieldList = arcpy.ListFields("Sediment1999", field_type="Double")
 
fieldNames = [f.name for f in fieldList ]
 
for name in fieldNames :
    Kriging45 = arcpy.GeostatisticalDatasets("C:\\Users\\courtney\\Desktop\\MundleStableIsotope\\Kriging45.lyr")
    Kriging45.Sediment1999 = "C:\\Users\\courtney\\Desktop\\MundleStableIsotope\\StableIsotopeData.gdb\\Sediment1999"
    Kriging45.Sediment1999name = name
    arcpy.GACreateGeostatisticalLayer_ga("C:\\Users\\courtney\\Desktop\\MundleStableIsotope\\Kriging45.lyr", "C:\\Users\\courtney\\Desktop\\StableIsotopeData.gbd\\Sediment1999 name", "GaLayer"+name)
    arcpy.GALayerToRasters_ga("GALayer"+name, (os.path.join("C:\\Users\\courtney\\Desktop\\MundleStableIsotope\\Anisotropic\\Sediment\\1999", name+".tif")), "PREDICTION")
    
arcpy.CheckInExtension("GeoStats")

 

EDIT: Below is the error message I get.

 

Traceback (most recent call last):
  File "C:\Python27\ArcGIS10.4\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
    exec codeObject in __main__.__dict__
  File "E:\Work\Miscellaneous\Mundle Stable Isotope\KrigingCodeYearSpecific.py", line 20, in <module>
    arcpy.GACreateGeostatisticalLayer_ga("C:\\Users\\courtney\\Desktop\\MundleStableIsotope\\Kriging45.lyr", "C:\\Users\\courtney\\Desktop\\StableIsotopeData.gbd\\Sediment1999 name", "GaLayer"+name)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\ga.py", line 1297, in GACreateGeostatisticalLayer
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 045001: Input dataset(s) error. Table of inputs is not complete.
Failed to execute (GACreateGeostatisticalLayer).

 

Thanks so much,

 

Courtney

Outcomes