I'm looking to get some input into interpolating multiple point feature classes using a for loop.Whenever I specify to run only 1 feature class in the for loop, the script completes. BUT, when I specify all feature classes, it loops through each step with the first feature class fine and when moving to the next feature class, I get an error saying "workspace or data source is read only" and "The operation was attempted on an empty geometry" or "no spatial reference exists" at the interpolation step.I noticed that for each interpolation and extraction that works on a single feature class, a new raster grid is saved in my env.workspace path using default naming parameters, as well as in the savepaths that I have defined myself. Is it possible that the reason why I get the "workspace is read only" error is due to python reading the default file that is saved to my workspace automatically? I've also tried using the ".save" function to store the new raster grids, which you will see are commented out because they did not work. As an alternative I used the Copy Raster tool to save the output raster grids to new geodatabases.
import arcpy
from arcpy import env
from arcpy.sa import *
#Set up environmental workspace
env.workspace = "C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\S_Gauges\SGaugeTest.gdb"
#Set up save path
#clipsavepath = "C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\S_Gauges\S_Gauge_Clips.gdb"
krigsavepath = "C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\S_Gauges\Krig_Test.gdb"
Extractsavepath = "C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\S_Gauges\Krig_Mask_Test.gdb"
# Define constant variables
BasinBound = "C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\S_Gauges\S_Gauges.gdb\S_BasinBoundary"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
fcs=arcpy.ListFeatureClasses("a*")
print "Listing feature classes"
for fc in fcs:
print (fc)
try:
#outclip = clipsavepath + "/" + fc + "_" + "clip"
outkrigsave = krigsavepath + "/" + fc + "_" + "krig"
outmasksave = Extractsavepath + "/" + fc + "_" + "krigmask"
zfield = "Wlevel"
#Clip gauge data with basin boundary
#print 'clipping gauge data'
#arcpy.Clip_analysis(fc,BasinBound,outclip)
# Run kriging Interpolate
print 'interpolating gauge data'
outkrig = Kriging(fc,zfield, KrigingModelOrdinary ("Spherical",0.0008333333333),0.0008333333333)
#outkrig.save=(outkrigsave)
# Copy krig to gdb
print 'copying interpolation grid to new gdb'
arcpy.CopyRaster_management(outkrig,outkrigsave)
# Extract krig interpolation by the corresponding basin mask
print 'extracting interpolation with basin mask'
outmask = ExtractByMask(outkrig,BasinBound)
#outmask.save = (outmasksave)
# Copy krig to gdb
print 'copying interpolation grid to new gdb'
arcpy.CopyRaster_management(outmask,outmasksave)
except:
# If an error occurred print the message to the screen
print arcpy.GetMessages()
print 'Script is complete!!'
Here is a copy of the error messages
*** Remote Interpreter Reinitialized ***
>>>
Listing feature classes
a734184
interpolating gauge data
copying interpolation grid to new gdb
extracting interpolation with basin mask
copying interpolation grid to new gdb
a734072
interpolating clipped gauge data
Executing: Kriging C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\S_Gauges\S_Gauges.gdb\a734072 Wlevel C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\S_Gauges\S_Gauges.gdb\Kriging_a7345 "Spherical 0.000833" 0.0008333333333 "VARIABLE 12" #
Start Time: Mon Mar 17 15:44:56 2014
ERROR 999999: Error executing function.
Workspace or data source is read only.
Workspace or data source is read only.
No spatial reference exists.
ERROR 010029: Unable to create the raster __1000000.
Failed to execute (Kriging).
Failed at Mon Mar 17 15:44:56 2014 (Elapsed Time: 0.00 seconds)
Thanks for taking the time to read through this.