Dr. Cho’s Website
Course Materials

Profile extraction using ArcPy

Dr. Huidae Cho
Institute for Environmental and Spatial Analysis...University of North Georgia

1   Data set

In this lecture, we will perform various spatial analyses using ArcPy.

Add all the layers in the nc_spm_08_grass7_exercise data set.

2   Extract the profile of a selected stream

Hints

  • Get the Raster object of the elevation.tif layer
  • Get the NumPy array of the elevation.tif layer
  • Get the selected stream polyline
  • Densify the stream line using half the mean elevation cell width
  • Loop through vertices in the densified stream line
  • For each vertex
    • Convert x and y to row and column
    • Read the elevation.tif cell value at row and column

Three-dimensional plots

from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(x, y, z)
plt.show()

x, y = np.meshgrid(range(elev_a.shape[1]), range(elev_a.shape[0]))
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_surface(x, y, elev_a)
plt.show()