Estoy tratando de introducir un raster en GRASS desde R y volver a sacarlo usando el rgrass7
paquete. Introducir la trama no parece ser un problema. Sin embargo, cuando intento sacarlo con el readRAST
parece que las dimensiones de la trama se han reducido a [1,1].
¿Me falta algún argumento de la función? Todos los ejemplos que he visto utilizan simplemente el nombre del objeto GRASS.
¿Es un problema de mapset? No lo creía porque tenía entendido que la filosofía de rgrass7
es utilizar conjuntos de mapas y capas temporales.
Ver ejemplo reproducible:
library(raster)
#> Loading required package: sp
raster_image <- raster::raster(system.file("external/test.grd", package = "raster"))
raster_image <- as(raster_image, "SpatialGridDataFrame")
loc <- rgrass7::initGRASS("/usr/lib/grass70", home = tempdir(), override = TRUE)
rgrass7::writeRAST(raster_image, "raster_image", flags = c("overwrite"))
#> 0% 3% 6% 9% 12% 15% 18% 21% 24% 27% 30% 33% 36% 39% 42% 45% 48% 51% 54% 57% 60% 63% 66% 69% 72% 75% 78% 81% 84% 87% 90% 93% 96% 99% 100%
rgrass7::execGRASS("r.info", map = "raster_image")
#> +----------------------------------------------------------------------------+
#> | Map: raster_image Date: Wed Jan 18 08:36:35 2017 |
#> | Mapset: file17053b43fb4e Login of Creator: jose |
#> | Location: file170531b5b35a |
#> | DataBase: /tmp/Rtmpn8cS5A |
#> | Title: ( raster_image ) |
#> | Timestamp: none |
#> |----------------------------------------------------------------------------|
#> | |
#> | Type of Map: raster Number of Categories: 0 |
#> | Data Type: DCELL |
#> | Rows: 115 |
#> | Columns: 80 |
#> | Total Cells: 9200 |
#> | Projection: x,y |
#> | N: 334000 S: 329400 Res: 40 |
#> | E: 181600 W: 178400 Res: 40 |
#> | Range of data: min = 128.434005737305 max = 1805.78002929688 |
#> | |
#> | Data Description: |
#> | generated by r.in.bin |
#> | |
#> | Comments: |
#> | r.in.bin --overwrite -d input="/tmp/Rtmpn8cS5A/file170531b5b35a/file\ |
#> | 17053b43fb4e/.tmp/josecomp/X530" output="raster_image" bytes=8 heade\ |
#> | r=0 bands=1 order="native" north=334000 south=329400 east=181600 wes\ |
#> | t=178400 rows=115 cols=80 anull=127 |
#> | |
#> +----------------------------------------------------------------------------+
out_raster <- rgrass7::readRAST("raster_image")
#> Creating BIL support files...
#> Exporting raster as floating values (bytes=8)
#> 0% 100%
dim(raster_image)
#> [1] 9200 1
plot(raster_image)
dim(out_raster)
#> [1] 1 1
plot(out_raster)
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
#> Error in seq.default(zlim[1], zlim[2], length.out = length(col) + 1): 'from' cannot be NA, NaN or infinite