e1179191

Looping fields of a shapefile for Kriging

Discussion created by e1179191 on Mar 5, 2011
The following code creates rasters (usign kriging) for each fields of a shapefile. I was asking some parts of the code, but fixed them, so decided just to share the code in case someone needs it.

import arcpy, os.path, glob, string
import string, arcpy, os, string
from arcpy import env
from arcpy.sa import *

env.workspace="E:\\for_J\\Excel.gdb"
arcpy.CheckOutExtension("Spatial")

shp = "E:\\for_J\\Excel.gdb\\Locations"

fcList = arcpy.ListFeatureClasses()
#Kriging = 0
Kriging = "E:\\for_J\\Excel.gdb\\s"
outVarRaster = "E:\\for_J\\out"

for fc in fcList:
    m = []
    fieldList = arcpy.ListFields("Locations")
    i = 0
    for fld in fieldList:
        if i >= 5:
            k = str(fld.name)
            m.append(k)
        i = i + 1

   
    for fld in m:#- this will read each value in list m.  The range of i is from 0 till the length of the list. The -1 is because the counter i starts at 0.
        outKrig = fld + "k"
        arcpy.gp.Kriging_sa(shp, fld, outKrig, "Spherical 0.012628", "1.26279999998001E-02", "VARIABLE 12", "")

Outcomes