10

How to you use GDAL to subset a smaller raster from a bigger one given the bounding coordinates?

1

2 Answers 2

12

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 
1

If you are using c++ coding in gdal , then yes, you can subset with VRTDataset(), here you can give your desired size of subset in vrtcreate(xsize,ysize) and then saving it with using createcopy().

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.