[GRASS-user] Help; Running Grass from R - SQLite database setup

Mehrdad Varedi varedi at gmail.com
Tue Aug 27 23:56:57 PDT 2019


Hi Everyone,
I used the code from Micha and managed to run grass in R and create a new
dataset from R. I can't see the SQLite database in the created folders like
the ones I usually get when creating new datasets from GRASS.

How can I have the new SQlite database?

Thanks for your help.


On Sun, Apr 28, 2019 at 10:55 AM Micha Silver <tsvibar at gmail.com> wrote:

> Maybe this will help:
>
> (You must have GRASS installed, of course)
>
>
> # Parameters for the GRASS installation and temporary GRASS mapset
>
> GISBase = "/usr/lib/grass76"
> # Set these as you like
>
> GISDbase = "/tmp"
> Location = "tmp_location"
> Mapset = "tmp_mapset"
> georef = "EPSG:2039"
>
> mapset_path = file.path(GISDbase, Location, Mapset)
>
> # Now run the 'grass' command within R and
>
> # use the -c and -e flags to create the temp mapset, then exit
>
> setup_grass_cmd = paste("grass", "-c", georef, "-e", mapset_path)
>
> system(setup_grass_cmd)
>
>
> # Load the R grass interface and initialize GRASS within R,
>
> # using the temporary mapset from above
>
> library(rgrass7)
> initGRASS(home=tempdir(),
>           gisBase = GISBase,
>           gisDbase = GISDbase,
>           location = Location,
>           mapset = Mapset,
>           remove_GISRC = TRUE)
>
>
> # Try some GRASS commands
>
> input_tif = "isrlat12.tif"
>
> grass_rast = "isrlat12"
> execGRASS("r.in.gdal",  flags = c("o","overwrite"),
>           input = input_tif,
>           output = grass_rast)
> execGRASS("g.region", flags="p", raster = grass_rast)
>
> I did not add a command to remove the temporary mapset.  Something like:
>
> unlink(file.path(GISDbase, Location), recusive = TRUE) might be necessary
>
> Micha Silver
>
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> cell: +972-523-665918
>
>

-- 
Mehrdad Varedi
ᐧ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20190828/557047f5/attachment-0001.html>


More information about the grass-user mailing list