7

I have a raster whose pixel values are 0 or 1 (b/w areas in the image below) and data type is Float32.

I made a point layer from each individual pixel's center. Then I made some calculation for all points and added it as new field.

enter image description here

How can I make a new raster, which has the same properties (resolution, pixel size, data type, etc.) with the first raster, from those point values?

3
  • 3
    Have you tried gdal_rasterize yet?: gdal.org/programs/gdal_rasterize.html
    – Aaron
    Sep 13 '20 at 17:37
  • @Aaron my ultimate goal is to assign point values to existing pixels. Since I want to try another ways, I have asked the question this way. I couldn't use gdal_proximity. I'm getting errors. But It looks like I will try to solve my problem by writing code instead of fixing errors. Sep 13 '20 at 19:22
  • 6
    +1 for gdal_rasterize which is available as the Rasterize tool in the QGIS Processing toolbox. You can specify the same extent and cellsize as your existing raster.
    – user2856
    Sep 14 '20 at 6:02
1

Maybe this would be the complete work-flow (as partially mentioned already by @Aaron and @user2856):

  1. make a copy of your original raster (so that extent, resolution, CRS etc. remain the same)
  2. use GDAL > Vector Conversion > 'Rasterize (Overwrite With Attribute)' tool (gdal:rasterize_over) to overwrite the raster's values with the values from your shapefile
0

The best solution I can think of is the inverse distance weighting (IDW) algorithm.

If you're having difficulty understanding the algorithm then this tutorial should help you out.

https://www.qgistutorials.com/en/docs/interpolating_point_data.html

2
  • 1
    The rasterize of processing might be better, since it will honour a one to one value (burn) a new value and not do an interpolation.
    – Jakob
    Nov 9 '20 at 12:13
  • That's very true. But in a situation where you want the output raster resolution to be higher than the original raster resolution then IDW might be a better option. Someone might find this useful. Nov 26 '20 at 10:31

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.