Given a raster with an overly large nodata surround, how can I automatically discard the surround? Said another way: how does one shrink the raster extent to only occupy the area containing values?

I know one can interactively draw a box and clip the raster, or zoom and export only visible extent, or set an analysis mask. I'm after a geoprocessing tool or simple python script. Tools at hand are ArcGIS with Spatial Analyst, QGIS, and GDAl/OGR, but really anything is fair game.

The example raster is 16bit signed integer, with -32768 defined as NoData, but the null value or bit level really shouldn't matter.

nodata extent is many times larger than the actual data extent

Browse other questions tagged or ask your own question.