1

How can I replicate in ArcPy the 3D Analyst Toolbar operations which extract an elevation profile from a transect line drawn atop an elevation layer? This will be incorporated into an automated workflow that will loop ~500K times. Hence, streamlining is critical.

Here's the procedure using the toolbar:

  1. Point toolbar to the elevation layer
  2. Click 'Interpolate Line' to draw the cross-section
  3. Click 'Profile Graph' to generate the profile
  4. Right-click graph, 'Export', 'Data'

(Inputs: elevation layer, transect. Outputs: graph, XY table.)

Rather than manually drawing a transect, as in the toolbar functions, I need the ability to specify the transect start & end by entering coordinates. Similar to the tool, I want the output to be XY pairs (ideally a numpy array), with x=0 being the transect origin, X-values being distance from origin, and Y-values being elevation.

4
  • 2
    Take a look at the stack profile tool as a starting point. This sample here shows the tool being used with input line. You could hack it to accept xy and make a line yourself using arcpy geometry. arcgis.com/home/item.html?id=9eb7c69d9d124a488a76e2cf5fe401e9
    – KHibma
    Feb 17, 2016 at 2:58
  • 1
    @KHimba: I just wanted to circle back and thank you for putting me on the right track. I've been able to use StackProfile exactly as I'd hoped.
    – joechoj
    Sep 8, 2016 at 7:36
  • 2
    Can you post your answer so we can see what you did? Sep 9, 2016 at 17:56
  • @Matthew: See updated answer.
    – joechoj
    Sep 12, 2016 at 21:59

1 Answer 1

2

Following up, the extremely straightforward solution (offered up by KHimba) is a built-in function that I was unfamiliar with, called StackProfile in the 3D Toolbox. Here's a condensed version of how I implemented it into my script:

patch = r'F:\Joe_School\Thesis\data\grid_extract\mask400_1'
out_prof = r'F:\Joe_School\Thesis\scripts\Jerry\scratch.gdb\testprof'

import arcpy, os
from arcpy import env
import arcpy.ddd as DDD

#env.overwriteOutput = True
env.outputCoordinateSystem = arcpy.Describe(patch).spatialReference
env.workspace = os.path.dirname(out_prof)

#Extract profile, save graph & table
arcpy.CheckOutExtension('3D')
tablename = 'prof_tablex'
graphname = 'prof_graphx'
prof = DDD.StackProfile(out_prof, patch, tablename, graphname)
DM.SaveGraph(graphname, graphname + '.bmp')
arcpy.CheckInExtension('3D')

In my full script, I was able to feed it a custom-built transect, and output the XY data into a numpy array, as originally intended.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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