I have a shapefile with several polygons, and I want to convert it to a raster file with 30mx30m (using QGIS 3.2).

I am using "Raster > Conversion > Rasterize", and I am having trouble with the values I have to use. So, for the "Input layer" I am obviously using the shapefile. In the "Field to use for a burn-in value", I am using a column which is filled with "1" values for all polygons. For the "Output raster size units", I am selecting "Pixels", and both "Width" and "Height" is 500.000000 (the pixel size seems to get smaller each time this value is increased, and I don't fully understand why). "Output Extent" has the same extent as the shapefile.

This is how part of the maps looks like (using the parameters above): enter image description here

And these are the properties I get in the file:

enter image description here

First question: I don't understand how the "Width" and "Height" values work; how do I set pixel size as 30m?

Second question: How do I get each dark pixel to be, for instance, "1", and the white pixel to be "0" (in a way that the raster is binary)? Or is this automatic?

  • Welcome to gis.stackexchange. Please note that the format of this Q&A site requires us to stick to one question per thread. Please edit your post to focus on one question only. Feel free to post any additional question in additional threads. – underdark Jun 28 '18 at 18:54

You are specifying the raster width/eight in terms of pixel, not the pixel width/height in terms of meters, so if the raster width is 10, it means the pixel size will be vector extent width divided by 10. As this number of pixels increases, the size of each pixel decreases.

Assuming your data projection is expressed in meters, you can choose the option raster resolution in map unit per pixel with a value of 30. The algorithm will compute the number of required pixels.

  • thank you, this worked perfectly! Another question; Pixel values are apparently all the same (according to the legend, black pixels are 1 and white pixels are 1 as well); how can I change the "white" for 0, or another value? – mtao Jun 28 '18 at 21:25

Basically, you are setting the definition of the raster (pixel count), not its spatial resolution (pixel size).

From my understanding, if you choose pixel in the Output raster size units dropdown, the next two fields are image width and height in pixels while if you choose Georeferenced units, the two next fields specify spatial resolution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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