Quantcast
Channel: Active questions tagged raster-calculator - Geographic Information Systems Stack Exchange
Viewing all articles
Browse latest Browse all 188

gdal_calc to replace null values of one raster with values of another not working

$
0
0

I have a raster containing NULL values in which I'd like filled

To do so, I have interpolated the raster via IDW in GDAL, and then used the QGIS raster calculator to perform the following calculation

(Original = 0) * Interpolated + (Original != 0) * Original

Basically, where there are data values of 0 in the original raster, replace them with the interpolated values. But if the the original rasters data values are anything other than 0 then keep the original value.

This runs perfectly in QGIS with no complaints and creates my new raster. So I decided to try it in GDAL using gdal_calc

gdal_calc -A original.tif -B interpolated.tif --outfile newraster.tif --calc="(-a = 0) * -b + (-a != 0) * -a"

However, I keep getting the error Error! Dimensions of file interpolated.tif (4138, 4902) are different from other files (7347, 8705). Cannot proceed

Even with adding the --extent=ignore flag it wont work


Viewing all articles
Browse latest Browse all 188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>