Dear Steve and all,I have read with attention posts about cokriging. I also have to produce cokriging with more than 2500 variables (Elevation+rainfall). I'm not sure to be in the good thematic but I try, because some of you have probably solved (I think) my problem in their script.I'm new in python and I don't manage lists. I would like to use them to create geostatical layer. I used model builder (models work) but I must write now cokriging script without model builder (export from model builder to python script is not enough...).So, I made list of shapefiles and list of values for the field rainfall. But I have this answer in the python shell:Traceback (most recent call last):
File "C:\INTERP\sCRIPT PYTHON\FC4.py", line 75, in <module>
inputDset1 = fc + NewList
TypeError: coercing to Unicode: need string or buffer, list found
I think that my code is not good and my lists must be transformed before to use them to create geost. layers. But I don't know how and where.......If someone have an idea, a solution? It would be great.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 = fc + NewList #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)
arcpy.env.autoCommit = tempEnvironment0
arcpy.env.spatialGrid1 = tempEnvironment1
ThanksNaho