<html style="direction: ltr;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body bidimailui-charset-is-forced="true" style="direction: ltr;"
text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 28/08/2019 9:56, Mehrdad Varedi
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CA+F3BSCzWBuk385aw3MVu3kuJ+5HLUupgMTqT6kQfRSGsVMV=A@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">Hi Everyone,
<div>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.</div>
<div><br>
</div>
<div>How can I have the new SQlite database? </div>
<div><br>
</div>
</div>
</div>
</blockquote>
<p><br>
</p>
<p>If you import some vector you'll have the sqlite.db setup for
you:</p>
<p>(Following the example from before)</p>
<p><br>
</p>
<p><tt>> input_vect = "Israel_border.gpkg"</tt><tt><br>
</tt><tt>> grass_vect = "isr_border"</tt><tt><br>
</tt><tt>> execGRASS("v.import", input=input_vect,
output=grass_vect, flags="o")</tt><tt><br>
</tt><tt>Over-riding projection check</tt><tt><br>
</tt><tt>Check if OGR layer <Israel_border> contains
polygons...</tt><tt><br>
</tt><tt> 100%</tt><tt><br>
</tt><tt>Creating attribute table for layer
<Israel_border>...</tt><tt><br>
</tt><tt>Default driver / database set to:</tt><tt><br>
</tt><tt>driver: sqlite</tt><tt><br>
</tt><tt>database:
$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db</tt><tt><br>
</tt><tt>Importing 1 features (OGR layer <Israel_border>)...</tt><tt><br>
</tt><tt> 100%</tt></p>
<p><tt><br>
</tt></p>
<p>Then in a separate terminal:</p>
<p><tt>micha@TP480:~$ ll /tmp/tmp_location/tmp_mapset/sqlite/</tt><tt><br>
</tt><tt>total 20</tt><tt><br>
</tt><tt>drwxr-xr-x 2 micha micha 4096 Aug 28 13:19 ./</tt><tt><br>
</tt><tt>drwxr-xr-x 6 micha micha 4096 Aug 28 13:19 ../</tt><tt><br>
</tt><tt>-rw-r--r-- 1 micha micha 12288 Aug 28 13:19 sqlite.db</tt><tt><br>
</tt><tt><br>
</tt></p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:CA+F3BSCzWBuk385aw3MVu3kuJ+5HLUupgMTqT6kQfRSGsVMV=A@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">
<div>Thanks for your help.</div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sun, Apr 28, 2019 at
10:55 AM Micha Silver <<a href="mailto:tsvibar@gmail.com"
moz-do-not-send="true">tsvibar@gmail.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div style="direction:ltr" bgcolor="#FFFFFF">
<blockquote type="cite">
<div dir="ltr">
<div>
<div>Maybe this will help:<br>
</div>
</div>
</div>
</blockquote>
<p>(You must have GRASS installed, of course)</p>
<p><br>
</p>
<p><font size="+1"><tt># Parameters for the GRASS
installation and temporary GRASS mapset</tt></font></p>
<p><font size="+1"><tt>GISBase = "/usr/lib/grass76"</tt></font><br>
<font size="+1"><tt><font size="+1"><tt><span
style="font-size:14px"># Set these as you like</span></tt></font></tt></font></p>
<p><font size="+1"><tt>GISDbase = "/tmp"</tt><tt><br>
</tt><tt>Location = "tmp_location"</tt><tt><br>
</tt><tt>Mapset = "tmp_mapset"</tt><tt><br>
</tt><tt>georef = "EPSG:2039"</tt><tt><br>
</tt><tt><br>
</tt><tt>mapset_path = file.path(GISDbase, Location,
Mapset)</tt></font></p>
<p><tt><font size="+1"># Now run the 'grass' command
within R and </font></tt><br>
</p>
<p><font size="+1"><tt># use the -c and -e flags to create
the temp mapset, then exit<br>
</tt></font></p>
<p><font size="+1"><tt>setup_grass_cmd = paste("grass",
"-c", georef, "-e", mapset_path)</tt></font></p>
<p><font size="+1"><tt>system(setup_grass_cmd)</tt></font></p>
<p><span style="font-size:14px"><font face="monospace"><font
size="+1"><br>
</font></font></span></p>
<p><span style="font-size:14px"><font face="monospace"><font
size="+1"># Load the R grass interface and
initialize GRASS within R, </font></font></span></p>
<p><span style="font-size:14px"><font face="monospace"><font
size="+1"># using the temporary mapset from above</font></font></span><br>
</p>
<p><font size="+1"><tt>library(rgrass7)</tt><tt><br>
</tt><tt>initGRASS(home=tempdir(), </tt><tt><br>
</tt><tt> gisBase = GISBase,</tt><tt><br>
</tt><tt> gisDbase = GISDbase,</tt><tt><br>
</tt><tt> location = Location,</tt><tt><br>
</tt><tt> mapset = Mapset,</tt><tt><br>
</tt><tt> remove_GISRC = TRUE)</tt><tt><br>
</tt></font></p>
<p><font size="+1"><tt><br>
</tt></font></p>
<p><font size="+1"><tt># Try some GRASS commands</tt></font></p>
<p><font size="+1"><tt>input_tif = "isrlat12.tif" <br>
</tt></font></p>
<p><font size="+1"><tt>grass_rast = "isrlat12"</tt><tt><br>
</tt><tt>execGRASS("r.in.gdal", flags =
c("o","overwrite"),</tt><tt><br>
</tt><tt> input = input_tif,</tt><tt><br>
</tt><tt> output = grass_rast)</tt><tt><br>
</tt><tt>execGRASS("g.region", flags="p", raster =
grass_rast)</tt><tt><br>
</tt></font><br>
</p>
<p>I did not add a command to remove the temporary
mapset. Something like:</p>
<p> <tt>unlink(file.path(GISDbase, Location), recusive =
TRUE)</tt> might be necessary</p>
<p>Micha Silver<br>
</p>
<pre class="gmail-m_-7760652768775255896moz-signature" cols="72">Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail_signature">Mehrdad Varedi</div>
</div>
<div hspace="streak-pt-mark" style="max-height:1px"><img alt=""
style="width:0px;max-height:0px;overflow:hidden"
src="https://mailfoogae.appspot.com/t?sender=admFyZWRpQGdtYWlsLmNvbQ%3D%3D&type=zerocontent&guid=21afc582-8b6f-47c9-ba1d-ef54adaa0dfb"
moz-do-not-send="true"><font size="1" color="#ffffff">ᐧ</font></div>
</blockquote>
<pre class="moz-signature" cols="72">--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
</body>
</html>