I'm not an expert in python, however I have to write a script to do geostatistical analyses with the GACreateLayer function from Arcgis.
I have several data (>2000) and I want to use list of features and list of field values to perform cokriging.
I have written a script, the first part return list of features in my gdb and the list of values in the field that I have chosen (it works and return field values and feature names) and the second part do cokring (it works for one feature and its field)
However when I want to use both lists (inputDSet, end of script) in order to create a GA Layer it doesn't work.
File "C:\Program Files\ArcGIS\Desktop10.0\ArcPy\arcpy\ga.py", line 921, 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)
I don't know how correctly use lists? May I transform them or something else?
Here, is my code:
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
def listFcsInGDB():
# list all Feature Classes in a geodatabase
gp.workspace = "C:\\INTERP\\PJ_class.gdb"
fcs = []
for fds in gp.ListDatasets('','feature') + ['']:
for fc in gp.ListFeatureClasses('','',fds):
#yield os.path.join(fds, fc)
fcs.append(os.path.join(fds, fc))
return fcs
fcs = listFcsInGDB()
for fc in fcs:
print fc
# List of value in fields
input_dataset = fc
Atts = 'PJ_RacPJ' #field with rainfall values
rows = gp.searchcursor(fc)
row = rows.next()
NewList = []
for fc in fcs:
for row in gp.SearchCursor(fc):
fcValue = row.getvalue(Atts)
NewList.append(fcValue)
#print NewList
arcpy.CheckOutExtension("GeoStats")
# Load required toolboxes
arcpy.ImportToolbox("C:/Documents and Settings/ArcGIS/Toolbox.tbx")
# Local variables:
Cokriging_xml = "C:\\INTERP\\COK_.xml"
CK = "CK2"
ids1 = "C:\\INTERP\\data.gdb\\dem1000"
for fc in fcs:
for fcValue in NewList:
inputDset1 = fcValue #Variables
inputDset2 = ids1 #Covariable
InputDset = "inputDset1;inputDset2"
# Create cokriging layer (code from model builder)
tempEnvironment0 = gp.autoCommit
arcpy.env.autoCommit = "1000"
tempEnvironment1 = gp.spatialGrid1
arcpy.env.spatialGrid1 = "0"
arcpy.GACreateGeostatisticalLayer_ga(Cokriging_xml,InputDset,CK) ##Function
arcpy.env.autoCommit = tempEnvironment0
arcpy.env.spatialGrid1 = tempEnvironment1
I need help.
If someone has an idea? It would be great.
Thanks