"g.list" in rgrass7 returns an integer and not a char. vector

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

"g.list" in rgrass7 returns an integer and not a char. vector

Mathieu Rajerison
Hi List,

I try to get the list of rasters which are in my working environment but
the result of execGRASS("g.list") is an integer, not a character vector

Why is that ?

> execGRASS("g.list", type="raster", pattern="global*") %>% class()
global_glob_rad_day1
global_glob_rad_day2
global_glob_rad_day3
[1] "integer"

How to get a list of my rasters as a character ?

Thaks in advance for any guidance,

Mathieu

here is my sessionInfo() :
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252
LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] bindrcpp_0.2.2     rgrass7_0.1-12     XML_3.98-1.16
gdalUtils_2.0.1.14 forcats_0.3.0      stringr_1.3.1      dplyr_0.7.6
 [8] purrr_0.2.5        readr_1.1.1        tidyr_0.8.1        tibble_1.4.2
     ggplot2_3.0.0      tidyverse_1.2.1    raster_2.6-7
[15] sp_1.3-1           sf_0.6-3

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17      lubridate_1.7.4   lattice_0.20-35   class_7.3-14
  assertthat_0.2.0  psych_1.8.4       foreach_1.4.4
 [8] R6_2.2.2          cellranger_1.1.0  plyr_1.8.4        e1071_1.6-8
 httr_1.3.1        pillar_1.2.3      rlang_0.2.1
[15] lazyeval_0.2.1    readxl_1.1.0      rstudioapi_0.7    R.utils_2.6.0
 R.oo_1.22.0       rgdal_1.3-3       foreign_0.8-70
[22] munsell_0.5.0     broom_0.4.5       compiler_3.5.1    modelr_0.1.2
  pkgconfig_2.0.1   mnormt_1.5-5      tidyselect_0.2.4
[29] codetools_0.2-15  crayon_1.3.4      withr_2.1.2
 R.methodsS3_1.7.1 grid_3.5.1        nlme_3.1-137      spData_0.2.9.0
[36] jsonlite_1.5      gtable_0.2.0      DBI_1.0.0         magrittr_1.5
  units_0.6-0       scales_0.5.0      cli_1.0.0
[43] stringi_1.1.7     reshape2_1.4.3    xml2_1.2.0
iterators_1.0.10  tools_3.5.1       glue_1.2.0        hms_0.4.2
[50] parallel_3.5.1    yaml_2.1.19       colorspace_1.3-2  classInt_0.2-3
  rvest_0.3.2       bindr_0.1.1       haven_1.1.2

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: "g.list" in rgrass7 returns an integer and not a char. vector

Micha Silver

On 12/04/2019 15:15, Mathieu Rajerison wrote:
Hi List,

I try to get the list of rasters which are in my working environment but
the result of execGRASS("g.list") is an integer, not a character vector

Why is that ?

execGRASS("g.list", type="raster", pattern="global*") %>% class()
global_glob_rad_day1
global_glob_rad_day2
global_glob_rad_day3
[1] "integer"

How to get a list of my rasters as a character ?


Adding intern=TRUE to the execGRASS command works for me:


> execGRASS("g.list", type="rast", pattern="meron*", intern=TRUE) %>% class
[1] "character"


-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: "g.list" in rgrass7 returns an integer and not a char. vector

Mathieu Rajerison
Thanks a lot !

Le ven. 12 avr. 2019 à 15:05, Micha Silver <[hidden email]> a écrit :

>
> On 12/04/2019 15:15, Mathieu Rajerison wrote:
>
> Hi List,
>
> I try to get the list of rasters which are in my working environment but
> the result of execGRASS("g.list") is an integer, not a character vector
>
> Why is that ?
>
>
> execGRASS("g.list", type="raster", pattern="global*") %>% class()
>
> global_glob_rad_day1
> global_glob_rad_day2
> global_glob_rad_day3
> [1] "integer"
>
> How to get a list of my rasters as a character ?
>
>
> Adding intern=TRUE to the execGRASS command works for me:
>
>
> > execGRASS("g.list", type="rast", pattern="meron*", intern=TRUE) %>% class
> [1] "character"
>
>
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> cell: +972-523-665918
>
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo