<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>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">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>
      <font size="+1"><tt></tt><tt></tt></font></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><tt></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"><font color="#ffffff" size="1">ᐧ</font></div>