How to use gdal utilities to subset from a raster?

gdal_translate

gdal_translate -projwin ulx uly lrx lry inraster.tif outraster.tif`

Or

gdal_translate -srcwin xoff yoff xsize ysize inraster.tif outraster.tif

-projwin ulx uly lrx lry: Selects a subwindow from the source image for copying with the corners given in georeferenced coordinates.

-srcwin xoff yoff xsize ysize: Selects a subwindow from the source image for copying based on pixel/line location.

EDIT: Can you subset a region from a vrt ?

gdal_translate -projwin ulx uly lrx lry inraster.vrt outraster.tif
gdal_translate -of VRT -projwin ulx uly lrx lry inraster.tif outraster.vrt

Tags:

Gdal