Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

EDIT: Can you subset a region from a vrt ?

share|improve this question
1  
See gfoss.blogspot.it/2008/06/gdal-raster-data-tips-and-tricks.html --> Extracting spatial subset (subregion) –  markusN Oct 3 '12 at 6:59
add comment

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer
add comment

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().

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.