[GIS] Understanding min and max values with Mosaic to New Raster

arcgis-10.2arcgis-desktopdemmosaicraster

I have to combine several DEM rasters into one from this source: http://srtm.csi.cgiar.org/SELECTION/inputCoord.asp, so I use Mosaic to New Raster tool.

I set up the tool:

  1. I input the rasters (all from the same source, same size and no projection);
  2. Set up the Pixel Type (32 bit floating point as in the original rasters);
  3. Set up the Cell size as the original rasters;
  4. Number of Bands = 1 as the original rasters; Mosaic Operator, I have done it with BLEND and MEAN (I get the same result).

The problem I have is that the resultant mosaic shows a different range of maximum and minimum values than the maximum and minimum values of the individual raster e.g., raster 1 (-5123.8, 23.25), raster 2 (-5974.6, 40.09), raster 3 (-57770.2, 38), raster 4 (-2534.3, 23.55), and final mosaic raster (-5975.8, 81.1).

I guess this solution is not right, at least I didn't expect to get that.
Anybody has an idea if this is ok, and if this is not, how to solve it and get a proper mosaic raster with right maximum and minimum values?

I am using ArcGIS 10.2.2 for Desktop.

Best Answer

As whuber mentioned, often statistics found in the raster properties are sometimes approximate or are out-of-date. They are predetermined properties that can be misleading to the actual raster values.

Calculated your own min / max values from 100% of the actual data using NumPy arrays. See Working with NumPy in ArcGIS, and RasterToNumPyArray (arcpy). E.g.:

import arcpy

inrast = r'C:\data\inRaster.tif'
my_array = arcpy.RasterToNumPyArray(inrast)
print((my_array.min(), my_array.max()))

If you have missing values (NODATA) then a masked array is needed to get the correct stats:

import numpy as np
my_array = arcpy.RasterToNumPyArray(inrast)
my_masked_array = np.ma.masked_equal(my_array, arcpy.Raster(inrast).noDataValue)
print((my_masked_array.min(), my_masked_array.max()))

Also, you don't need ArcGIS to read rasters as NumPy arrays; e.g. GDAL or rasterio can do similar.

Related Question