1

I have a slope raster and a road raster. The black pixels in the road raster are NoData values and the pink pixels have a value of 1. They don't cover exactly the same area. enter image description here

I want to create a new raster based on the slope raster, except for pixels where there is a road pixel. If there is a road pixel, I want to assign a value of zero to the slope raster.

I am not quite sure how the formula needs to look like. I tried the following, put it didn't give me the expected results:

r.mapcalc "output = ((Slope+(Road*null())))"

Any ideas?

ustroetz
  • 7,994
  • 10
  • 72
  • 118

1 Answers1

3

Use this r.mapcalc expression:

r.mapcalc "output = not(if(Road))*Slope"

because:

  • if(Road)is equal to 1 if Road not zero, 0 otherwise.
  • not(if(Road))is equal to 0 if Road not zero, 1 otherwise.
Antonio Falciano
  • 14,333
  • 2
  • 36
  • 66