RGRASS7 and Initgrass
On Wed, 4 May 2016, PONS Frederic - CEREMA/DTerMed/DREC/SRILH wrote:
Dear all I am working on windows 7. I have update my version of GRASS GIS 7.0.4 and R-3.2.5. I try to work with my old tools and I meet a problem with function InitGrass. i just want to share this problem and if possible understand if the problem depend on my installation of grass and r or release of InitGrass.
You have not said which version of rgrass7 you are using. I'm afraid this is very unclear. You are almost certainly using a very suboptimal approach. Have you thought of starting GRASS properly once, and doing whatever your function does in new mapsets? Or are the locations different? Please move this to the grass-stats list. After an error, do run traceback(). And establish first that initGRASS() works run in the R session itself rather than in a function (I doubt that this is easy to debug). Roger PS: Please note that the link to github is *not* the source, it is an unauthorised copy, and as maintainer I refuse to consider any references to it. The released source is on CRAN, and the development trunk may be browsed on R-Forge. Just "thinking" is no use, if you run under debug(), give the line number of specific issues.
Before I can use: loc=initGRASS(gisBase = Chemin_de_l_exe_de_Grass,home=Chemin_des_donnees_Grass,gisDbase=Chemin_des_donnees_Grass,location=Localisation,mapset=Jeu_de_donnees,override=T) I have this problem: Error in if (class(t0) != "try-error" && is.character(t0) && nchar(t0) > : missing value where TRUE/FALSE needed I thonk it is in this osurce code: https://github.com/cran/rgrass7/blob/master/R/xml1.R I solve the problem uisng a false folder loc=initGRASS(gisBase = Chemin_de_l_exe_de_Grass,home=Chemin_des_donnees_Grass,gisDbase=Chemin_des_donnees_Grass,addon_base=Chemin_de_l_exe_de_Grass,location=Localisation,mapset=Jeu_de_donnees,override=T) Best regards File: C:\Program Files\R\R-3.2.5\Cerema #Chemin de l'exe de Grass C:\GRASS GIS 7.0.4 #Monde Grass temporaire (1=oui, 0=non) 0 #Chemin des donnees Grass C:\GRASSDATA #Localisation Cerema #Jeu de donnees test #Projection (EPSG) 2154 #Chemin des routines R C:/PROGRA~1/R/R-32~1.5/cerema Code: # DICARTO_00_LectureMondeGrass # Version 2.0 06/10/2015 # Cerema # Frederic Pons, Celine Trmal DICARTO_00_LectureMondeGrass = function(chem_routine,Numero_de_calcul) { # Lecture de l'initialisation et cr??ation du monde Grass fichier_init=paste(chem_routine,"\\Init_Routine_Cerema",as.character(Numero_de_calcul),".txt",sep="") fid=file(fichier_init, open = "r") lignes <- readLines(fid) close(fid) Chemin_de_l_exe_de_Grass=as.character(lignes[2]) Chemin_des_donnees_Grass=as.character(lignes[6]) Localisation=as.character(lignes[8]) Jeu_de_donnees=as.character(lignes[10]) Projection=as.numeric(lignes[12]) Monde_grass_temp=as.numeric(lignes[4]) if (Monde_grass_temp==0) { loc=initGRASS(gisBase = Chemin_de_l_exe_de_Grass,home=Chemin_des_donnees_Grass,gisDbase=Chemin_des_donnees_Grass,addon_base=Chemin_de_l_exe_de_Grass,location=Localisation,mapset=Jeu_de_donnees,override=T) ## convert default coordinate system x,y to epsg code 3347 (can be altered later) #execGRASS("g.mapset",flags=c("c"),parameters=list(mapset="PERMANENT")) #execGRASS("g.proj",flags=c("c"),epsg=as.integer(Projection)) #execGRASS("g.mapset",flags=c("c"),parameters=list(mapset=Jeu_de_donnees)) } else { loc=initGRASS(Chemin_de_l_exe_de_Grass, home=tempdir(),addon_base=Chemin_de_l_exe_de_Grass,override=T) } return(cbind(Chemin_de_l_exe_de_Grass,loc$GISDBASE,loc$LOCATION,loc$MAPSET,Projection)) } *Fr?d?ric Pons * *Expert hydraulique sur les inondations et al?as c?tiers **DREC/Service Risques Inondations Littoraux et Hydraulique **- T?l.: (33)4 42 24 76 68 * *Direction Territoriale M?diterran?e * Centre d??tudes et d?expertise sur les risques, l?environnement, la mobilit? et l?am?nagement www.cerema.fr <http://www.cerema.fr>
Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 91 00 e-mail: Roger.Bivand at nhh.no http://orcid.org/0000-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en http://depsy.org/person/434412