Using Arcpy, how can I determine min and max elevation from a raster DEM layer within my current extent? I'm currently using Data Driven Pages to centre the layout on each feature extent.
I need to determine this elevation difference value in order to get Python to automatically activate the appropriate contour interval feature class (25m, 100m, etc)
The current logic I'm thinking of is to select all cells within current extent, (what is the most convenient way, or arcpy methods() to do this?) place their values in a list, then:
minElev = 99999
maxElev = -99999
for i in myList:
if i < minElev:
minElev = i
for i in myList:
if i > maxElev:
maxElev = i
then subtract max and min to get the difference value.
I don't think this is the easiest way, is there someone experienced who knows a faster way?
Best Answer
Use Get Raster Properties, specifically the
MINIMUM
andMAXIMUM
values.In theory, this code should make a temporary raster layer using the display extent -- although I have not tested it, and am not sure whether it will work -- and then the raster properties tool will apply to only the raster currently shown in the display.