[GRASSLIST:1512] system() & R
Cannata, Massimiliano
massimiliano.cannata at supsi.ch
Fri Oct 17 05:54:40 EDT 2003
Hello users,
i write an R script that execute temperature interpolation
inside a GRASS environmental.
Now all i want to do is write a GRASS command that send
some variable and command to my system.....
After having started my GRASS section i have to run my
command, set my variable and then trogth the C system()
command start my R section, execute my script.R and quit
R.
My problem is that after starting R section my system do
not go on..... is waiting for command input.....
Have you the solution?
Follows my code:
//variable setted
timestamp = input->answer;
dtm=elevation->answer;
//start R
system("R;");
//delete all variable
system("rm(list = ls());");
//set the R variable Ttime & dem
command = strcat("Ttime<-'",(const char*)timestamp);
command = strcat(command,"' > /home/tmp.txt");
system(command);
printf(command);
command = strcat("dem<-'",(const char*)dtm);
command = strcat(command,"' > /home/tmp.txt");
system(command);
printf(command);
//run my R script
system("source(/home/mcannata/Rscript/temper.R)>tmp.txt");
printf("eleboration running...");
//write my Raster to GRASS
command = "rast.put(G,lname=";
strcat(command,(const char*)timestamp);
strcat(command,",Temperatura$t)");
printf(command);
//delete redirected output
system("rm /home/tmp.txt");
//stop R session
system("q()");
--------------------------------------
Eng. Massimiliano Cannata
Phd student
www.supsi.ch
More information about the grass-user
mailing list