3

I want to create a 1000m grid over a 1000m land cover map such that the grid cells are perfectly aligned with the raster pixel underneath. But when I use the Create Grid function in QGIS, the cells and pixels are misaligned (understandably). The screenshot below illustrates this problem. What can I do to align the cells and pixels?

enter image description here

1 Answer 1

1

First Possibiliy: create grid based on raster layer

Make sure your grid is created in the same CRS as the raster layer. Set the Grid extent to the extent of the raster layer (click ... next to this field) and choose the same horizotal and vertical pixel size (copy this information form the layer properties of the raster layer):

enter image description here

Senond possibility: Raster pixels to polygons

As an alternative, you can run Menu Processing / Toolbox / Raster pixels to polygons. The resulting polygons will also contain the pixel value of one of the raster's bands. For huge rasters, processing can take a while.

4
  • I'm already doing all that :( problem is that the grid extent is a rectangle around the raster layer and not the raster itself, and that seems to be causing the misalignment
    – Ryan Ma
    Jul 11, 2021 at 15:53
  • 1
    OK, this is important information that should be included in the question! So maybe the raster is not in its original CRS? Can you add more information or provide your data for testing?
    – Babel
    Jul 11, 2021 at 15:57
  • 2
    Try Raster pixels to polygons, see updated answer
    – Babel
    Jul 11, 2021 at 16:13
  • The second method works. Thanks!
    – Ryan Ma
    Jul 12, 2021 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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