I have been trying to create a python scrip to batch process .dat files (with .hdr files).The data is PRISM Temperature, Precip etc... data which are stored as .dat files - for all the type of functions I need, ArcGIS spatial analyst tools can do it if I do them 1-by-1. I have 3,100 files that need processing. This is what I need to happenMask the PRISM data to the study area.Convert PRISM .dat to ASCIII tried adapting the code I found below# Extracts the cells of a raster that correspond with the areas
# defined by a mask.
# Author: Michel
# Date: 10 de Janeiro de 2011
# -----------------------------
# Import system modules
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
try:
# Check out any necessary licenses
gp.CheckOutExtension("spatial")
# Load required toolboxes...
gp.AddToolbox("C:/Program Files (x86)/ArcGIS/Desktop10.0/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")
gp.workspace = "C:/Users/ken/Desktop/GIS Model/FinalProjectData/PRISM_Binary/test"
out_workspace = "C:/Users/ken/Desktop/GIS Model/FinalProjectData/PRISMPrecip"
mask = "C:/Users/ken/Desktop/GIS Model/FinalProjectData/PolygonStudyArea/polygonstudyarea.shp"
# Get a list of the rasters in the workspace
raster = gp.ListRaster()
# Loop through the list of rasters
raster.reset()
raster = raster.next()
while raster:
# Set the outputname for each output to be the same as the input
output = out_workspace + raster
# Process: Extract by Mask...
gp.ExtractByMask_sa(raster, mask, output)
# Loop function...
raster = raster.next()
except:
# If an error occurred while running a tool, then print the messages.
print "Error in script"
print gp.GetMessages()
But I've read that the tool in python has a known error that won't process .datThe python code I cobbled clumsily together for mass converting to ASCII had no luck# Description: Converts a raster datasets to an ASCII file representing
# raster data from a foler.
# Requirements: arcpy
# Author: Kenneth
# Import system modules
import arcpy
from arcpy import env
try:
# Set environment settings
env.workspace = "C:/Users/ken/Desktop/GIS Model/FinalProjectData/PRISM_Binary/test"
out_workspace = "C:/Users/ken/Desktop/GIS Model/FinalProjectData/PRISMPrecip"
# Set local variables
raster = env.ListRaster()
#loop through raster list
raster.reset()
raster = raster.next()
while raster:
#set output name for each to be same as input
outASCII = out_workspace + rasterlist
# Execute RasterToASCII
arcpy.RasterToASCII_conversion(raster, outASCII)
#loop function
raster = raster.next()
except:
# If an error occurred while running a tool, then print the messages.
print "Error in script"
Is there any other way I can mass change these files? I appreciate any help.