<div dir="ltr">Thank you for your time and sharing your knowledge Micha for the second time.<div><br></div><div>I followed your code and found that initGRASS searches for libraries and binaries of GRASS in gisBase folder. If we address a folder that doesn't have the code it comes back with this error message: "The code execution cannot proceed because libgrass_gis.7.4.1.dll was not found. Reinstalling the program may fix this problem." it gives the same error even if I copy that file into GISBase folder.</div><div><br></div><div>I want to run my code on a shiny server which I can't install GRASS although I can copy files and libraries. Can I solve this issue by copying a certain folder of GRASS binaries with my app or I am going the wrong path?</div><div><br></div><div>Please advise,</div><div><br></div><div>Thank you once again for all the time you share to answer my questions,</div><div><br></div><div>Mehrdad</div><div><br></div><div><br></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=6036490f-455f-4578-9a0d-ec0122c7134a"><font color="#ffffff" size="1">ᐧ</font></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">
<br>
<div class="gmail-m_5578967118729247329moz-cite-prefix">On 27/04/2019 22:05, Mehrdad Varedi
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr"><br clear="all">
<div>Hi Everyone,
<div>I have detail explanations of connecting to an existing
dataset in GRASS from R in this address: <a href="https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7" target="_blank">https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7</a></div>
<div><br>
</div>
<div>What I hope I could do is to create a GRASS dataset in R
on the fly and without the need to install GRASS or create a
dataset on it. Is there any way to do this?</div>
<div><br>
</div>
</div>
</div>
</blockquote>
<p>Maybe this will help:</p>
<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><br>
</p>
<p>One other note: you probably will get better suggestions on the
R-sig-geo list...</p>
<p><br>
</p>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>i.e. I have a vector /raster file and use that to
identify the region and details required to set up a dataset
and use GRASS functions just by including rgrass library.</div>
<div><br>
</div>
<div>Thanks for your help and attention,</div>
<div><br>
</div>
<div>Mehrdad</div>
</div>
-- <br>
<div dir="ltr" class="gmail-m_5578967118729247329gmail_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=dbe7ab29-5a21-45c9-97bb-082f4f48224a"><font size="1" color="#ffffff">ᐧ</font></div>
<br>
<fieldset class="gmail-m_5578967118729247329mimeAttachmentHeader"></fieldset>
<pre class="gmail-m_5578967118729247329moz-quote-pre">_______________________________________________
grass-user mailing list
<a class="gmail-m_5578967118729247329moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a>
<a class="gmail-m_5578967118729247329moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/grass-user</a></pre>
</blockquote>
<pre class="gmail-m_5578967118729247329moz-signature" cols="72">--
Micha Silver
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>