7

I want to convert a raster file (100x100m pixel size) which contains population counts as pixel values. I need a vector-based file of the 100x100m grids and the population as attributes.

I tried different conversion methods in QGIS, but there will always be pixels merged together.

Is there a way to create a vector grid and assign the raster values to them?

Taras
  • 32,823
  • 4
  • 66
  • 137
boondigga
  • 71
  • 1
  • 1
  • 2

3 Answers3

7

Yet another option would be SAGA Raster values to points tool (QGIS Processing Toolbox | SAGA | Vector <-> raster). Choose [1] cells as Type option.

SAGA - Raster values to points

enter image description here

note white moth-eaten appearance, which is nodata holes.


It was not clear what particular tools you have already tried, but one of them might have been GRASS r.to.vect tool (Type: area), which yields something like you have described: GRASS - r.to.vect

enter image description here

note internal nodata cells are treated as independent parts by GRASS

Taras
  • 32,823
  • 4
  • 66
  • 137
Kazuhito
  • 30,746
  • 5
  • 69
  • 149
4

Alternatively you can do it directly with OpenJUMP Plus. Open your raster as a Sextante raster layer and use this tool

enter image description here

As a result you'll get a polygon layer that contains the pixel values as attributes. The other option "Create Lattice" creates points instead of polygons. In the image below blue rectangles are the generated polygons and attribute info is shown from the two selected and highlighted polygons.

enter image description here

Taras
  • 32,823
  • 4
  • 66
  • 137
user30184
  • 65,331
  • 4
  • 65
  • 118
4

Since QGIS 3.4 there is an algorithm called "Raster pixels to polygons".

You can find it in the Processing Toolbox -> Vector creation -> Raster pixels to polygons

enter image description here

For more details check the pull requests on GitHub.

Taras
  • 32,823
  • 4
  • 66
  • 137
Francisco Puga
  • 4,618
  • 21
  • 40