How to transform NA values in to 0 in a raster layer

I am currently working with climate data from Chelsa Database.
Their variables related to snow and frost have a problem that in places where it rarely or never snows variables have NA values instead of 0.
I can't use na.omit or something similar because it erases the cell from the raster, and then I can't work with the variable.
Does anyone have a solution to this problem?

1 Like

Hi @GabrielYan , if the data is dtb,
Remmember put a reproducible example for better understand all the community.

Try with this:

dtb<- dtb %>% replace(, 0)

Hi, as mentioned, a reproducible example would help.

These might work though:

Replacing NAs with 0 for raster data using R - Geographic Information Systems Stack Exchange

Replace NA's with 0 for large raster data using R? - Geographic Information Systems Stack Exchange

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.