Sunday, 22 March 2015

Export GRASS raster as GeoTIFF : nodata values exported as -nan (what happens in R?)


I am using the package raster to work with GeoTIFF raster files which I exported from GRASS using r.out.gdal. GRASS assigned the value -nan to some raster files (type FLOAT32) for missing values. Other files had 65535 or 255 assigned to missing values.


In R, I reassign these values to missing like this:


raster[raster==255] <- NA


The problem is that I do not know what to do with multiple rasters that had the -nan assigned to missing values. For what I see when I examine the structure of these rasters (which I have as part of a list), the -nan are stored as NaN.I tried doing:


rasterlist[["element_i"]][rasterlist[["element_i"]] == NaN] <- NA


but I do not see any difference, for example when I do:


getValues(rasterlist[["element_i"]], row=1000)



The output is something like:


8100 NaN 8101 NaN NaN 8102 8104 8106


so the NaN are not transformed into NA.


Any suggestion?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...