[GRASS-user] raster exchange between GRASS and R with nodata

Paulo van Breugel p.vanbreugel at gmail.com
Thu Sep 4 04:46:08 PDT 2014


You probably have good reasons for your work flow, but just to make sure:
is there a specific reason to export to geotiff first? It seems easier to
import the raster layer directly from GRASS into R using the spgrass6
package (readRAST6)? You can subsequently convert the spatial raster to the
raster format.




On Thu, Sep 4, 2014 at 11:32 AM, Johannes Radinger <
johannesradinger at gmail.com> wrote:

> Hi,
>
> I want to export a raster map (FCELL) from GRASS70 to the geotiff format
> using r.out.gdal and to import it later on in R. The map contains many no
> data values.
>
> Here some details about the raster:
> Type of Map:  raster               Number of Categories: 0
> Data Type:    FCELL
> Rows:         750
> Columns:      750
> Total Cells:  562500
> total null and non-null cells: 15105636
> total null cells: 15105047
>
> So when I export the map, r.out.gdal reports: "Input raster map contains
> cells with NULL-value (no-data). The value -nan will be used to represent
> no-data values in the input map. You can specify a nodata value with the
> nodata option."
>
> When I subsequently try to import the geotiff into R (using the package
> 'Raster') the nodata values are not recognised as NA's:
>
> a <- raster("*.tif")
> summary(a)
> Min.     0.5294496
> 1st Qu.  0.7171210
> Median   0.7871540
> 3rd Qu.  1.1581826
> Max.     1.5494517
> NA's     0.0000000
>
> So I am wondering if I need to set any specific parameter during the
> export (r.out.gdal) or import (raster()).
>
> As I am not only exporting FCELL (Float32) raster but also multiple
> (N=500) other rasters to R I would be interested in a solution also for
> DCELL (Float64). Of course I can export all of as Float64 as the file size
> should not be a problem.
>
> Any suggestions or experiences of handling NA's during raster exchange
> between GRASS and R?
>
> /Johannes
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20140904/99aca2a1/attachment.html>


More information about the grass-user mailing list