Hello, I am reading these information, which are really useful for me. According to your discussion. I already can do the kriging using python for a given shpfile. I don't know how to do the loop. What you use for the loop. As here we can not use iterators from model bulider. Thanks a lot!!!!
Dear all,
I have a similar problem, I am trying to automatically process some shapefiles in order to use cokriging.
This is the python code:
# Import arcpy module
import arcpy
# Check out any necessary licenses
arcpy.CheckOutExtension("GeoStats")
arcpy.env.overwriteOutput = True
# Local variables:
#CoKriging = "C:\\Users\\nkondapalli\\Desktop\NewFolder\\CoKriging.lyr"
CoKriging = "C:\\Users\\nkondapalli\\Desktop\NewFolder\\Krigingmodel2_2.xml"
TR1intermediate_point = "C:\\Users\\nkondapalli\\Desktop\NewFolder\\TR1intermediate_point.shp"
GACreateGeostatisticalLayer1 = "C:\\Users\\nkondapalli\\Desktop\NewFolder\\GACreateGeostatisticalLayer5"
#GALayerToPoints2 = "C:\\Users\\nkondapalli\\Documents\\ArcGIS\\Default.gdb\\GALayerToPoints5"
GALayerToGri2 = "C:\\Users\\nkondapalli\\Desktop\NewFolder\\GALayerToGri2"
GALayerToPoints2_PointToRast = "C:\\Users\\nkondapalli\\Documents\\ArcGIS\\Default.gdb\\GALayerToPoints5_PointToRast"
test2ASCII_TXT = "C:\\Users\\nkondapalli\\Desktop\NewFolder\\"#test2ASCII.TXT"
numFiles=5
# Process: Create Geostatistical Layer
for i in range(2,3):#numFiles+1):
print "C:\\Users\\nkondapalli\\Desktop\NewFolder\\RG1intermediate_point_%d.shp X=Shape Y=Shape F1=DATA;C:\\Users\\nkondapalli\\Desktop\NewFolder\\TR1intermediate_point_%d.shp X=Shape Y=Shape F1=DATA"%(i,i)
arcpy.GACreateGeostatisticalLayer_ga(CoKriging, "C:\\Users\\nkondapalli\\Desktop\NewFolder\\RG1intermediate_point_%d.shp X=Shape Y=Shape F1=DATA;C:\\Users\\nkondapalli\\Desktop\NewFolder\\TR1intermediate_point_%d.shp X=Shape Y=Shape F1=DATA"%(i,i), GACreateGeostatisticalLayer1)
# Process: GA Layer To Points
#arcpy.GALayerToPoints_ga(GACreateGeostatisticalLayer1, TR1intermediate_point, "", GALayerToPoints2)
# Process: GA Layer To Grid
arcpy.GALayerToGrid_ga(CoKriging, GALayerToGri2, "0.063", "1", "1")
# Process: Point to Raster
#arcpy.PointToRaster_conversion(GALayerToPoints2, "OBJECTID", GALayerToPoints2_PointToRast, "MOST_FREQUENT", "NONE", "0.05")
# Process: Raster to ASCII
print 'print to file : '+'file%d.txt'%i
arcpy.RasterToASCII_conversion(GALayerToGri2, test2ASCII_TXT+"file%d.txt"%i)
and this is the error:
C:\Users\nkondapalli\Desktop\NewFolder\RG1intermediate_point_2.shp X=Shape Y=Shape F1=DATA;C:\Users\nkondapalli\Desktop\NewFolder\TR1intermediate_point_2.shp X=Shape Y=Shape F1=DATA
Traceback (most recent call last):
File "C:\Users\nkondapalli\Desktop\NewFolder\testErik3.py", line 36, in <module>
arcpy.GALayerToGrid_ga(CoKriging, GALayerToGri2, "0.063", "1", "1")
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\ga.py", line 1341, in GALayerToGrid
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input geostatistical layer: Dataset C:\Users\nkondapalli\Desktop\NewFolder\Krigingmodel2_1.xml does not exist or is not supported
WARNING 000725: Output surface raster: Dataset C:\Users\nkondapalli\Desktop\NewFolder\GALayerToGri2 already exists.
Failed to execute (GALayerToGrid).
It looks like the error is in the xml file. We actually modified it, inserting optimize = "ByCrossvalidation" and changing the options auto to "true".
Any clue?
Thanks!
Michele
Hi,
I need some help with the error I get while using spatial analyst tool in a python script (attached).
Due to hard disk space issues, I deleted most of the old data files in the default.gdb folder and tried to run the script, which was working fine before the data clean-up.
Below is the error message I get.
Please help me identify what is missing and how to fix the issue.
Thanks,
Anushuya
Executing: Script
Start Time: Sun Aug 10 15:47:46 2014
Running script Script...
Traceback (most recent call last):
File "C:\Users\aramakrishnan\Documents\ArcGIS\scratch\Ordinary Kriging_July2014.py", line 41, in <module>
arcpy.gp.ExtractValuesToPoints_sa(Harris_Lat_Long_csv_Events_lyr, Raster_Path + "OZ4" + fieldname, Ext_Table_Path + "OZ4" + fieldname, "INTERPOLATE", "VALUE_ONLY")
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 999999: Error executing function.
Failed to execute (ExtractValuesToPoints).
Failed to execute (Script).
Failed at Sun Aug 10 15:49:38 2014 (Elapsed Time: 1 minutes 51 seconds)
What happens if you run the ExtractValuesToPoints geoprocessing tool from the toolbox and feed in your raster and point feature class? I.e. in your script you could print out the raster name and the name of the feature class.
Also, the GALayerToPoints tool exports a geostatistical layer to points. The tool can also be used to predict values at unmeasured locations or to validate predictions made at measured locations.
This route will save you creating a raster.
-Steve