I have many files with name format yyyymmddhhmm_tprate.asc 201508010600_tprate.asc , 201508011200_tprate , 201508011800_tprate, 201508020000_tprate and so on ..........

I want to subtract 201508011200_tprate - 201508010600_tprate, 201508011800_tprate-201508011200_tprate and so on and want to save these files with a new name.


1) You could try to convert your ascii files to rasters:

 import arcpy,os,re
 from arcpy import env
 from arcpy.sa import *

 arcpy.env.workspace = (r"<where ascii files are">)
 out_dir = (r"<Where you want them to go>")

  asciilist = arcpy.ListDatasets("*","ASCII")
  count = 1
  for ascii in asciilist:
     outRaster = arcpy.ASCIIToRaster_conversion(ascii, "", "INTEGER")
     outname = os.path.join(out_dir, str(ascii)) # Create the full out path

2) You can try a raster calculator workaround using the answer to Raster Calculator Workaround in Arcpy for Suitabiliy Analysis

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.