I have two raster A and B. A and B have the same grid size but different extent.
How can I make A have the same number of columns and rows, as well as the spatial extent of B?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Depending upon which platform you are using, with Arc you need to ensure, before clipping, that you set your Environment Settings: Geoprocessing>Environments... Set both Processing Extent and Raster Analysis to the extent of the layer to which you wish to clip, and set also your Cell Size to the cell size of the clip raster(not the input raster).
In QGIS use GRASS plugin thru Sextante would be the quickest way, alternatively do directly through GRASS.
Source: Advanced GIS graduate course taken last year, heaps of raster experience.
ArcMap Data Management Tools > Raster > Raster Processing > Clip should do it. However I found that sometimes, if the grid cells of the raster do not overlap perfectly, i.e. the two rasters are not perfectly georeferenced, Clip might retrieve a result with a slightly different number of columns and rows, generally a difference of 1. For instance, if the extent of raster A is desired to be the same as B, e.g. 20 x 20, Clip might return a raster of 20 x 21. Using the Georeferencing toolbar to perfectly georeference the images might help. Also, as Bryce Touchstone suggested, I found Geoprocessing environment is very helpful, and I also recommend filling in the Snap Raster dropdown menu with the relevant dataset.
Clip raster A by B using the Clip (Data Management) tool under Data Management - Raster - Raster processing.