<div dir="ltr">Thank you Micha,<div><br></div><div>I was under the impression that rgrass7 library has all the functions in GRASS. Apparently, all it does is calling modules from GRASS and GRASS should be completely installed on the same machine that the R code is running. I wish at least we could connect to a GRASS copy on a web-based VM.  </div><div>I enjoyed the part of your letter that explained how to created a dataset outside of GRASS using R code and thanks for that! </div><div><br></div><div>I wish it was possible to read the functions directly from a web host/cloud instead of installing it everywhere (Even if it was a paid service it could be an attractive option). ESRI has some API, I wish we could have it for GRASS or I could help to write the API for GRASS.</div><div><br></div><div>Best regards,</div><div><br></div><div>Mehrdad</div><div><br></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=b66b05e5-9b4f-4241-b8d5-f18c8aa8b6e4"><font color="#ffffff" size="1">ᐧ</font></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 28, 2019 at 2:54 PM 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_-5423386785276844233moz-cite-prefix">On 28/04/2019 19:30, Mehrdad Varedi
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <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>
    </blockquote>
    <p><br>
    </p>
    <p>I have no idea.</p>
    <p><br>
    </p>
    <p>So you're trying to run an application that's not installed? I
      can't imagine how that would work :-(. After all the libraries
      (*.dll's if this is windows) are searched for in a certain OS
      defined path. And many libraries depend on others, so the whole
      chain has to be found. </p>
    <p>What are the limitations on this server? Can you compile a binary
      into your home directory? If so, you might be able to install
      grass with the GISBASE in your home directory, and run from there.
      But again, GRASS has lot's of dependencies: proj4, gdal, and many
      others.  Any you need access to the compile toolchain...<br>
    </p>
    <p> </p>
    <p><br>
    </p>
    <p>Maybe others will have some more insight.</p>
    <p><br>
    </p>
    <p>Regards, Micha</p>
    <p><br>
    </p>
    <blockquote type="cite">
      <div dir="ltr">
        <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 size="1" color="#ffffff">ᐧ</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" target="_blank">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_-5423386785276844233gmail-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>
            </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><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_-5423386785276844233gmail-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_-5423386785276844233gmail-m_5578967118729247329mimeAttachmentHeader"></fieldset>
              <pre class="gmail-m_-5423386785276844233gmail-m_5578967118729247329moz-quote-pre">_______________________________________________
grass-user mailing list
<a class="gmail-m_-5423386785276844233gmail-m_5578967118729247329moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a>
<a class="gmail-m_-5423386785276844233gmail-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_-5423386785276844233gmail-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-m_-5423386785276844233gmail_signature">Mehrdad Varedi</div>
    </blockquote>
    <pre class="gmail-m_-5423386785276844233moz-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>