I am using QGIS 2.6 on Windows 7.
I have generated two rasters from vector layers. They cover the same extent and have the same projection (Irish Transverse Mercator) and cell size (5m x 5m). I have 'reclassified grid values' to ensure that both rasters now have values of only 0 or 10. I have been attempting to add the rasters together in the raster calculator ("NPWS@1"+"CH_Extract@1") and I am expecting to see values of 0, 10 or 20 (where there is overlap between the two original vector datasets). Instead I get an output layer with values of 0 or 9.989990. I have tried every permutation I can think of to fix this and am having no joy.
Answer
The problem is that your individual rasters are not aligned. So, when they are added the result is a weighted average for the values in the overlaping area. To solve this you have to use a merged vector layer whose extension must be used for producing individual raster. I used this procedure for testing it:
1) I created two vector layers (both with the same value field = 10) where they are overlaped in some area:
2) I merged them and I wrote down its extension:
3) Using the extension to rasterize (by value field = 10) the first vector layer:
4) First vector layer rasterized:
5) Second vector layer rasterized:
6) sum_raster obtained by using raster calculator. You can observe that the sum is 20 in overlaped areas (Value Tool plugin). The values: 0 (black area), 10 (gray area), 20 (white area).
No comments:
Post a Comment