When I stack a raster (using the stack function in the raster R package) that has a nodata value of -3.4e+38 and then write the raster to a tif, the nodata value becomes apart of the value range for the raster (min of -3.4028234663853e+38).The minimum value of the original raster was 0. How do I get my code to recognize the nodata value and not incorporate it as a value in the output raster? Note that the output raster also has a nodata value (when I look at the raster properties in QGIS) of -3.4e+38.
Here is my code:
temp_10m<-raster("temp_10m.tif")
stack<-stack(temp_10m)
save(stack, file = "temp_test.Rdata")
writeRaster(stack, filename=names(stack), bylayer=TRUE,format="GTiff", overwrite=TRUE)