Hi Steve,
I've send you the XML.
With regard to my second question, I now get this error:
AttributeError: ResultObject: Get attribute rootMeanSquare not found
However, if I use the option to write the results out to the point file it does work.
Best regards,
Gerrit
Please email me the XML file, I.e after you hit Finish in the Wizard then on the MethodReport dialog choose Save and send me (slynch@esri.com) this XML file.
For your second question,
GACreateGeostatisticalLayer2 is the name of the Geostatistical layer and not a variable I guess and therefore it should be in quotes, viz.
results = arcpy.CrossValidation_ga("GACreateGeostatisticalLayer2")
-Steve
I am trying to automate the cokriging process to test the different kriging parameters. I have created a geostatistical layer with the wizard and now I am trying to change the parameters with the Set Model Parameters Tool, however I am having trouble with the Xpath for some of the parameters.
Here is my code for setting the parameters:
params = "/model[@name = 'Kriging']/model[@name = 'Variogram']/value[@name = 'Anisotropy'];\
/model[@name = 'Kriging']/model[@name = 'Variogram']/model[@name = 'VariogramModel']/value[@name = 'ModelType'];\
/model[@name = 'Kriging']/model[@name = 'Variogram']/value[@name = 'LagSize'];\
/model[@name = 'Kriging']/model[@name = 'Variogram']/value[@name = 'NumberOfLags']"
The Xpath for the last two (LagSize and NumberOfLags) work fine, however the first two (Anisotropy and ModelType) does'nt work.
Can you show me where I went wrong?
Additionally, I am trying to print the RMSE results of the cross validation tool with some python script I found on the ESRI resource center, but it doesn't work:
results = arcpy.CrossValidation_ga(GACreateGeostatisticalLayer2)
print "RMSE: " + str(results.rootMeanSquare)
Any ideas?
Gerrit(Stellenbosch)
#Set environment arcpy.env.workspace = "C:/INTERP/PJ.gdb" # Check out Geostatistical Analyst extension license. gp.CheckOutExtension("GeoStats") #Variables and loop inputGA = "C:/INTERP/COK.xml" # fc = list component/ fcs = list for fc in fcs: #1st variable /"PJ" = targetfield inputDset1 = fc + " "+ "X=Shape Y=Shape "+ "F1=" +"PJ" #2nd variable inputDset2 = "C:/INTERP/data.gdb/dem" VARCOVAR = inputDset1 + ";" + inputDset2 #outLayer out = "cok" outLayer = out + fc # Process : GACreateGeostatisticalLayer for fc in fcs: gp.GACreateGeostatisticalLayer(inputGA,VARCOVAR,outLayer) print gp.GetMessages()
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
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
Yes it is in memory. To persist it use the SaveToLayerFile geoprocessing toolSteve
Run the CreateGeostatisticalLayer geoprocessing tool and then look at the syntax reported in the processing dialog.Steve
Hi Steve Lynch,With your help, I have finally find the way to do the programming, I think I can finish it soon. Thank you very very....much!Best regards,Yumei
I need to automate the production of my xml files (I have 120 xml files to produce, which will then be applied to cokrig more files using the code discussed above).The only parameter I am changing in the cokriging process is to press the "optimize model" button.Can I cokrig two shapefiles & "optimize" the model using Python, then alter the script to loop through my 120 files?Thank you,Brenna
Create a cokriging Geostatistical layer, then use this in the Create Geostatistical Layer GP tool and you'll notice from the results posted to results dialog that you are missing a semicolon between the 2 input datasets.Viz.,GACreateGeostatisticalLayer "Ordinary Cokriging" "C:\\Data\ca_ozone_pts.shp f1;C:\Data\ca_ozone_pts.shp f2" GAL1Steve
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.