Re: [GRASS-user] rgrass7 syntax for passing a command
Hi again, On a second look I tried: execGRASS("v.in.ascii", flags="n", input="-", output=" outlet1", Sys_input="636645|218835") That worked for me on Ubuntu... Cheers Stefan -Original Message- From: grass-user [mailto:grass-user-boun...@lists.osgeo.org] On Behalf Of Roger Bivand Sent: 29. april 2016 09:18 To: grass-user@lists.osgeo.org Subject: Re: [GRASS-user] rgrass7 syntax for passing a command Simply, don't. execGRASS() is for executing single GRASS commands, not a drop-in replacement for bash. Try something like creating the point in R with the correct projection, and write that vector object to your mapset: library(sp) library(rgrass7) pt <- SpatialPointsDataFrame(matrix(c(636645, 218835), ncol=2), proj4string=CRS(paste(execGRASS("g.proj", flags="j", intern=TRUE), collapse=" ")), data=data.frame(x=1)) writeVECT(pt, "outlet") You could create a temporary text file to read in: tf <- tempfile() writeLines("636645, 218835", tf) execGRASS("v.in.ascii", input=tf, output="outlet1", separator=",", flags="n") which is closer to your script but less natural. Yes, grass-stats is a more appropriate list. Roger - Roger Bivand NHH Norwegian School of Economics, Bergen, Norway -- View this message in context: http://osgeo-org.1560.x6.nabble.com/rgrass7-syntax-for-passing-a-command-tp5263330p5263427.html Sent from the Grass - Users mailing list archive at Nabble.com. ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] rgrass7 syntax for passing a command
Simply, don't. execGRASS() is for executing single GRASS commands, not a drop-in replacement for bash. Try something like creating the point in R with the correct projection, and write that vector object to your mapset: library(sp) library(rgrass7) pt <- SpatialPointsDataFrame(matrix(c(636645, 218835), ncol=2), proj4string=CRS(paste(execGRASS("g.proj", flags="j", intern=TRUE), collapse=" ")), data=data.frame(x=1)) writeVECT(pt, "outlet") You could create a temporary text file to read in: tf <- tempfile() writeLines("636645, 218835", tf) execGRASS("v.in.ascii", input=tf, output="outlet1", separator=",", flags="n") which is closer to your script but less natural. Yes, grass-stats is a more appropriate list. Roger - Roger Bivand NHH Norwegian School of Economics, Bergen, Norway -- View this message in context: http://osgeo-org.1560.x6.nabble.com/rgrass7-syntax-for-passing-a-command-tp5263330p5263427.html Sent from the Grass - Users mailing list archive at Nabble.com. ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] rgrass7 syntax for passing a command
Hi Jim, Although this does not solve you pipe issue (you might need to use pipe or fifo (run: help(pipe) in R for more info) : If you just want to create a map with one point you could also use “v.edit» in non interactive mode (I guess), meaning, create a map and add a point. Or you write your coordinates to a temporary file, which you can read in v.in.ascii Cheers Stefan From: grass-user [mailto:grass-user-boun...@lists.osgeo.org] On Behalf Of Veronica Andreo Sent: 28. april 2016 19:38 To: James Maas (MED) <j.m...@uea.ac.uk> Cc: grass-user <grass-user@lists.osgeo.org> Subject: Re: [GRASS-user] rgrass7 syntax for passing a command Hello Jim, Maybe you should write to grass-stats mailing list, too. Perhaps someone there can provide useful insights/suggestions for your case Best, Vero 2016-04-28 12:53 GMT-03:00 Jim Maas <j.m...@uea.ac.uk<mailto:j.m...@uea.ac.uk>>: Using GRASS 7.0.3 on Ubuntu Linux, I'm attempting to recreate the example of r.stream.distance shown at https://grass.osgeo.org/grass70/manuals/addons/r.stream.distance.html by passing these comands to GRASS from within an R session. I can't figure out the correct syntax to pass this command to the system and also GRASS, any suggestions ? The original code for GRASS command line in the example is # Create outlet echo "636645,218835" | v.in.ascii -n input=- output=outlet separator="," I've tried lots of combinations of both system() and execGRASS() including this system(message ("327500.00,523896.55") | "v.in.ascii", input="-", output="outlet", separator=",", flags=c("n", "overwrite")) but have been unsuccessful. Any suggestions? Thanks, J -- Dr. Jim Maas Norwich Medical School ___ grass-user mailing list grass-user@lists.osgeo.org<mailto:grass-user@lists.osgeo.org> http://lists.osgeo.org/mailman/listinfo/grass-user ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] rgrass7 syntax for passing a command
Hello Jim, Maybe you should write to grass-stats mailing list, too. Perhaps someone there can provide useful insights/suggestions for your case Best, Vero 2016-04-28 12:53 GMT-03:00 Jim Maas: > Using GRASS 7.0.3 on Ubuntu Linux, > > I'm attempting to recreate the example of r.stream.distance shown at > https://grass.osgeo.org/grass70/manuals/addons/r.stream.distance.html > > by passing these comands to GRASS from within an R session. I can't > figure out the correct syntax to pass this command to the system and also > GRASS, any suggestions ? > > The original code for GRASS command line in the example is > > # Create outlet > echo "636645,218835" | v.in.ascii -n input=- output=outlet separator="," > > > I've tried lots of combinations of both system() and execGRASS() including > this > > system(message ("327500.00,523896.55") | "v.in.ascii", input="-", > output="outlet", separator=",", flags=c("n", "overwrite")) > > > > > but have been unsuccessful. > > Any suggestions? > > Thanks, J > > -- > Dr. Jim Maas > Norwich Medical School > > ___ > grass-user mailing list > grass-user@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/grass-user ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] rgrass7 syntax for passing a command
Using GRASS 7.0.3 on Ubuntu Linux, I'm attempting to recreate the example of r.stream.distance shown at https://grass.osgeo.org/grass70/manuals/addons/r.stream.distance.html by passing these comands to GRASS from within an R session. I can't figure out the correct syntax to pass this command to the system and also GRASS, any suggestions ? The original code for GRASS command line in the example is # Create outlet echo "636645,218835" | v.in.ascii -n input=- output=outlet separator="," I've tried lots of combinations of both system() and execGRASS() including this system(message ("327500.00,523896.55") | "v.in.ascii", input="-", output="outlet", separator=",", flags=c("n", "overwrite")) but have been unsuccessful. Any suggestions? Thanks, J -- Dr. Jim Maas Norwich Medical School ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user