Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
    
Chad, Thank you for your answer. Indeed, I thought that your proposition could resolve the problem, however replace quotes by [ ] doesn't work. I have searched for the exact expression in arcgis 10 and the result is: arcpy.GACreateGeostatisticalLayer_ga("C:/INTERP/COK_.xml","C:/INTERP/PJ_class.gd‌​b/j01012003 X=Shape Y=Shape F1=PJ_RacPJ;C:/INTERP/Data.gdb/dem1000", "GACreateGeostatisticalLayer1") So, all arguments are in quotes: model, inputs and output. It works for one feature (variable) and its covariable (here a DEM). Maybe the problem comes from the lists. Could I simply use lists as I wrot –  nagosa Feb 20 '12 at 20:20
add comment

1 Answer

If I'm interpreting the help on this correctly, in_datasets for GACreateGeostatisticalLayer should be a comma-separated list of space-separated input dataset/input field pairs.

[inputDset1 field1, inputDset2 field2]

You also have them in quotes - InputDset = "inputDset1;inputDset2" - which could be a problem since they are variables; when in the quotes they could be getting interpreted as strings.

I haven't tested any of this, just some thoughts of things to look at.

share|improve this answer
    
Chad, Thank you for your answer. Indeed, I thought that your proposition could resolve the problem, however replace quotes by [ ] doesn't work. I have searched for the exact expression in arcgis 10 and the result is: arcpy.GACreateGeostatisticalLayer_ga("C:/INTERP/COK_.xml","C:/INTERP/PJ_class.g‌​d‌​‌​b/j01012003 X=Shape Y=Shape F1=PJ_RacPJ;C:/INTERP/Data.gdb/dem1000", "GACreateGeostatisticalLayer1") So, all arguments are in quotes: model, inputs and output. It works for one feature (variable) and its covariable (here a DEM). Maybe the problem comes from the lists... (1/2) –  nagosa Feb 21 '12 at 8:38
    
(2/2) Could I simply use lists as I wrote in my first post? Can I use them for applications without transform them into variables or something like that? Or must I do something specific? I have the list (first is a string list, second is a float list) and I don't have the answer.....Have you got any other idea? –  Aarthi Feb 22 '12 at 3:02
    
Above added to complete the question that the OP was asking the answerer. –  Aarthi Feb 22 '12 at 3:02
    
I found the problem, and how to answer to my question above. I put my code below if that can help ... To use a list in the GACreateGeostatisticalLayer:#Set environment arcpy.env.workspace = "C:/INTERP/PJ.gdb" # Check out Geostatistical Analyst extension license. gp.CheckOutExtension("GeoStats") –  nagosa Feb 22 '12 at 13:11
    
' Variables and loop <br/> inputGA = "C:/INTERP/COK.xml"<br/> #fc=list component/fcs=list<br/> for fc in fcs:<br/> #1st variable /"PJ" = targetfield<br/> inputDset1 = fc + " "+ "X=Shape Y=Shape "+ "F1=" +"PJ"<br/> #2nd variable<br/> inputDset2 = "C:/INTERP/data.gdb/dem"<br/> VARCOVAR = inputDset1 + ";" + inputDset2<br/> out = "cok"<br/> outLayer = out + fc<br/> # Process : GACreate<br/> for fc in fcs:<br/> gp.GACreateGeostatisticalLayer(inputGA,VARCOVAR,outLayer)'<br/> –  nagosa Feb 22 '12 at 13:47
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.