Hi everyone,
I am trying to use python to calculate storm pressure gradient (for many storms that occur on different dates) from the center of the storm westward. To do this, I have the .tif raster image for each date, as well as a corresponding line feature that extends to the west of the storm center. I want to use the line as a profile line to determine the average slope of the .tif file along that line. Here is my code:
import sys, os, arcpy, time, numpy, math, itertools
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
arcpy.CheckOutExtension("3D")
# set your local workspace (you'll need to edit this!)
arcpy.env.workspace = "F:\\Warm_Years_Data\\Surface\\t24_SLP\\Centers\\Lines_Tifs\\Subset\\"
output="F:\\Warm_Years_Data\\Surface\\t24_SLP\\Centers\\Lines_Tifs\\Subset\\"
# allow outputs to be overwritten (saves time if you need to debug)
arcpy.env.overwriteOutput = "True"
# have the program print out your workspace location
print "workspace set to " + arcpy.env.workspace
#Create a list of *.asc files
lineList = arcpy.ListFeatureClasses("*.shp")
print lineList
tifList = arcpy.ListRasters("*.tif")
#Loop to convert asc files in the list called "raster"
for shp, tif in itertools.izip(lineList, tifList):
base, ext = os.path.splitext(shp)
print "\n" + shp
print "\n" + tif
arcpy.AddSurfaceInformation_3d(shp, tif, "AVG_SLOPE", "LINEAR")
print "\n" + shp + " completed"
#Check in Spatial Analyst extension and remove variables (recommended "good practice" housekeeping)
arcpy.CheckInExtension("Spatial")
arcpy.CheckInExtension("3D")
del lineList
del tifList
However, when I run the code and check the attribute tables for "AVG_SLOPE" readings, all of these values are "0". Does anyone have any idea how this might be fixed?
Thanks in advance,
Jamie