# Extract Max & Min Values of Two Rasters [closed]

I have two raster datasets, the first an 800 meter digital elevation model, the second a corresponding set of temperatures at the same resolution and identical spatial reference.

I've extracted each into a smaller selection (elevation & temperature below):

Does a chunk of code exist that pulls the maximum and minimum values of one raster (in this case elevation), and extracts the values of the corresponding second raster (temperature)?

It's my goal to run this code for numerous smaller raster datasets.

My initial thought was to write code in ArcPy using the "Extract by Point" tool, however I discovered that this fell short of what I'm attempting to do.

## closed as off-topic by PolyGeo♦Jul 18 '17 at 21:46

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

First, you need to calculate the statistics on your raster, then you can use a tool in python GetRasterProperties to report the MIN/MAX values. Here is a bit of code that I use:

``````import os, sys, arcpy

ThisRas = sys.argv[1] # your input raster

d = arcpy.Describe(ThisRas)
if (d.bandCount == 1):
try:
arcpy.CalculateStatistics_management(ThisRas,1,1)
MinValR = arcpy.GetRasterProperties_management(ThisRas,"MINIMUM")
MaxValR = arcpy.GetRasterProperties_management(ThisRas,"MAXIMUM")
MinVal = float(MinValR.getOutput(0))
MaxVal = float(MaxValR.getOutput(0))