# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# PRISM2.py
# Created on: 2014-12-01 14:44:03.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: PRISM2 <clip_shp> <Output_Coordinate_System> <Geographic_Transformation> <R> <Input_Coordinate_System> <v_Name_> 
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")

# Script arguments
clip_shp = arcpy.GetParameterAsText(0)
if clip_shp == '#' or not clip_shp:
    clip_shp = "C:\\GIS\\PRISM\\S\\clip.shp" # provide a default value if unspecified

Output_Coordinate_System = arcpy.GetParameterAsText(1)
if Output_Coordinate_System == '#' or not Output_Coordinate_System:
    Output_Coordinate_System = "PROJCS['NAD_1983_UTM_Zone_12N',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-111.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]" # provide a default value if unspecified

Geographic_Transformation = arcpy.GetParameterAsText(2)

R = arcpy.GetParameterAsText(3)
if R == '#' or not R:
    R = "C:\\GIS\\PRISM\\R" # provide a default value if unspecified

Input_Coordinate_System = arcpy.GetParameterAsText(4)
if Input_Coordinate_System == '#' or not Input_Coordinate_System:
    Input_Coordinate_System = "Unknown" # provide a default value if unspecified

v_Name_ = arcpy.GetParameterAsText(5)
if v_Name_ == '#' or not v_Name_:
    v_Name_ = "C:\\GIS\\PRISM\\R\\PRISM\\%Name%" # provide a default value if unspecified

# Local variables:
Raster = R
v_name___3_ = Raster
Name = R
Resampling_Technique = "NEAREST"

# Process: Iterate Rasters
arcpy.IterateRasters_mb(R, "", "", "NOT_RECURSIVE")

# Process: Project Raster
arcpy.ProjectRaster_management(Raster, v_name___3_, Output_Coordinate_System, Resampling_Technique, "4358.61940021341", Geographic_Transformation, "", Input_Coordinate_System)

# Process: Extract by Mask
arcpy.gp.ExtractByMask_sa(v_name___3_, clip_shp, v_Name_)

