1

I am new to QGIS. I am trying to create a heat map based on area not points. What I want to acheive is similar to this question.

I want to create a binary raster (0 for no point, 1 for point). Then, use the outcome to create a heat map using r.neighbors.

So far I have done the following:

  1. Created a grid.
  2. Counted the number of points inside each grid count1615.

Now I want to convert the layer that has the number of points per grid (count1615) to create the binary raster.

  1. I went to Raster -> Conversion -> Rastersize (vector to raster).

However, the map I am getting only covers the areas with points. enter image description here

I want the raster to cover the entire map like in the below picture(white for points, black for no points). enter image description here

I tried to set my values to 0 and 1 in the raster conversion but it did not work. Since I am new to QGIS, I think my issue might be related to the output context option in the conversion phase. Or in selecting the cell sizes.

1 Answer 1

1

When creating a raster in QGIS, the default value of setting the NODATA value to 0 is set, so it is only visible but white(no color is assigned). In fact, the value is entered in the raster area you set.

Check this out.

Make sure the NODATA you set when rasterizing this is 0. If so, right-click on the created raster, go to properties, and uncheck the NODATA value in Transparency.

The color setting can be changed in the symbol.

There are cases where there is no value in your grid, and if you want to express the grid area in a raster, you will need more detailed settings or raster operation for values inside the grid, values outside the grid, and values in the grid with points.

EDIT

Make Two Ratster from count1615

RASTER 1 When rasterizing count1615, do not specify a field of values and put 0 as a fixed burn-in value. NODATA is set to 9999.

RASTER 2 Then, when rasterizing count1615, set the burn-in field to the field containing the calculated values for each grid. NODATA is set to 0.

SUM Two RASTER Sum the two raster using the raster calculator and set NODATA to 9999 in the Transparency of the resulting raster.

Now you have a raster set to 9999 out of bounds(not visible because it's set to NODATA). If there is a value in the zone it will have a value greater than 1, if there is no value it will be 0.

2
  • Thank you for your answer Urban87. I am intersted in achieving what you mentioned in your last paragraph. Because even after changing the transparency, the heat map does not look good. In addition, I could not apply the r.neighbors properly.
    – Myaccount
    Commented Mar 2, 2022 at 6:06
  • @Myaccount I've added the answer I think you want. I've only done this in Python, so I think there might be a better way in QGIS. Anyway, if you do that, you will get the result you want. And it doesn't really matter what the value is, since the problem of what you see is completely different depending on how you set up the symbol.
    – Urban87
    Commented Mar 2, 2022 at 7:36

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.