Select to view content in your preferred language

AddSurfaceInformation_3d Issues

597
1
05-07-2014 10:33 AM
JamieWard
New Contributor
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
Tags (1)
0 Kudos
1 Reply
TimBarnes
Frequent Contributor
Are you certain that your rasters and lines overlap and are in the same coordinate system?
How many raster/lines do you have in your workspace? It might be worth testing on a workspace containing just one line and one raster that you know are in the same space to verify your code works. It's also possible that the filenames in your lists for the raster and line files don't 'align' so addSurfaceInformation is comparing the wrong files.
0 Kudos