[GIS] Cell grid not aligning in QGIS

demqgisraster

I have been struggling with something since yesterday and Google did not help much…

I am working with two raster images, same projection (I re-projected one of them, they were originally different), same resolution and same extent. BUT the cell grids won't align. I am attaching a picture for you…

I tried a couple of things, like the align tool on QGIS and also re-sampling. The re-sampling "worked", the cell grid got aligned but the values of my DEM raster got all messed up… Is there any way I can "force" than to align? Any advice, tips?

enter image description here

Best Answer

When you reproject in QGIS, it is using something called gdalwarp under the hood. Try explicitly setting the -te (target extent) and -tr (target resolution) options explicitly to exactly match the raster you want to align to. These values are implicit if unspecified. To coerce conformity, you may also need to use the -tap (target aligned pixels) option, but depending on the alignment of your comparison (unprojected) raster, you may also have to warp that one in the same projection but with -tap on (ie warp both using -tap).

To do this, set up your warp command in the usual way and then click the yellow pencil button by the text box at the bottom of the dialog. You can now edit the gdalwarp command following the documentation.