import os
import fnmatch
import gdal
from subprocess import call


#folder path
input_folder = 'G:\\Walnut\\RealData\\'
output_folder = 'G:\\Walnut\\WalnutData\\'
projection = 26712  # NAD83 UTM Zone 12 North
x_min = 576863
y_min = 3501109
x_max = 637613
y_max = 3519609
cols = 2430
rows = 740
cell_size = 25
resample_method = 'average'
rcols = 243
rrows = 74
rcell_size = 250

os.chdir(input_folder)
def find_format(path, filter_):
    for root, dirs, files in os.walk(path):
        for file_ in fnmatch.filter(files, filter_):
            yield file_

for shapefile in find_format(input_folder, '*.shp'):
    FOLDER, shp_name = os.path.split(shapefile)
    raster_name, extent = os.path.splitext(shp_name)

    in_shp = os.path.join(input_folder, shp_name)
    temp = os.path.join(output_folder, 'temp.tif')
    # out_shp = os.path.join(output_folder, shp_name) # add reprojection later
    out_raster = os.path.join(output_folder, '{a}.tif').format(a=raster_name)

# rasterize
    raster = 'gdal_rasterize  -a SdvOutpu_1 -te {b} {c} {d} {e} -ts {f} {g} -tr {h} {h} -l {i} {j} {k}'.format(b=x_min, c=y_min, d=x_max, e=y_max, f=cols, g=rows,
                                                                                                               i=raster_name, j=in_shp, k=temp, h=cell_size)
    call(raster)
# warp
    warp = 'gdalwarp -overwrite  -s_srs EPSG:{a} -te {b} {c} {d} {e} -tr {f} {f} -r {g} -of GTiff {h} {i}'.format(a=projection, b=x_min, c=y_min, d=x_max,
                                                                            e=y_max, f=rcell_size, g = resample_method,
                                                                            h=temp, i=out_raster)
    call(warp)

    print "Done processing {a}".format(a=out_raster)


@@ -59,17 +59,16 @@
 t call%0A%0A
-%0A
 #folder 
@@ -71,16 +71,41 @@
 der path
+ and variables for Walnut
 %0Ainput_f
@@ -180,16 +180,19 @@
 Data%5C%5C'%0A
+%0A%0A%0A
 projecti
@@ -365,19 +365,23 @@
 rcols = 
-243
+cols/10
 %0Arrows =
@@ -385,27 +385,460 @@
 s = 
-74%0Arcell_size = 250
+rows/10%0Arcell_size = cell_size*10%0A%0A#folder path and variables for New Mexico%0Ainput_folder = 'G:%5C%5CETRM_inputs%5C%5CSoilsData%5C%5CNM_Extracted%5C%5CMerged%5C%5C'%0Aoutput_folder = 'G:%5C%5CETRM_inputs%5C%5CSoilsData%5C%5CNM_Ex..0tracted%5C%5CMerged%5C%5C'%0Aprojection = 26913  # NAD83 UTM Zone 12 North%0Ax_min = 114757%0Ay_min = 3471163%0Ax_max = 682757%0Ay_max = 4102413%0Acols = 22720%0Arows = 25250%0Acell_size = 25%0Aresample_method = 'average'%0Arcols = cols/10%0Arrows = rows/10%0Arcell_size = cell_size*10%0A
 %0A%0Aos

Add some NM parameters