I have:
raster_1
: an integer raster with non-sequential valuesi
(101, 130, 240, 323)i
: a watershed discharging X of sediment in the environmentraster_2
: represents the water quality for each watershedi
with values ranging from 0 to 100,000 - namedplume_i
I have ~400 rasters representing the water quality of 400 watersheds.
I would like to build a loop to set the values in raster_1
to NA
for each zone (defined by the values: 101, 130, 240, 323 in raster_1
) when raster_2
for the corresponding value (e.g., plume_101
) is 0, using R.
For instance,
- When
raster_1 = 101 & plume_101 = 0
, assignNA
toraster_1
otherwise returnraster_1
values - When
raster_1 = 130 & plume 130 = 0
, assignNA
toraster_1
otherwise returnraster_1
values - When raster_1 = 240 & plume 240 = 0, assign
NA
toraster_1
otherwise returnraster_1
values and so forth...
How can I do this?
plume_101
should only have values whereraster_1
is 101?