[GRASS-user] Help; Running Grass from R without installing GRASS
Mehrdad Varedi
varedi at gmail.com
Sun Apr 28 21:19:16 PDT 2019
Hi Stefan,
Thanks for your reply. I will try it in case of a permission issue.
Kind regards,
Mehrdad
ᐧ
On Sun, Apr 28, 2019 at 5:18 PM Stefan Blumentrath <
Stefan.Blumentrath at nina.no> wrote:
> Hi Mehrdad,
>
>
>
> If this is a permission issue, and the dependencies (and a build
> environment) are installed, you could try compile GRASS (and install it in
> your home directory if necessary with the --prefix configure option).
>
> svn checkout https://svn.osgeo.org/grass/grass/ grass_trunk
>
> cd grass_trunk
>
> ./configure
>
> make
>
> make install
>
> The make install step is not required for starting GRASS though. The make
> commando creates a bin…/ directory within the grass_trunk dir, where the
> grass startupscript is located…
>
>
>
> Hope that helps.
>
>
>
> Cheers,
>
> Stefan
>
>
>
>
>
>
>
> *From:* grass-user <grass-user-bounces at lists.osgeo.org> *On Behalf Of *Mehrdad
> Varedi
> *Sent:* søndag 28. april 2019 18:31
> *To:* Micha Silver <tsvibar at gmail.com>
> *Cc:* grass-user <grass-user at lists.osgeo.org>
> *Subject:* Re: [GRASS-user] Help; Running Grass from R without installing
> GRASS
>
>
>
> Thank you for your time and sharing your knowledge Micha for the second
> time.
>
>
>
> 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.
>
>
>
> 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?
>
>
>
> Please advise,
>
>
>
> Thank you once again for all the time you share to answer my questions,
>
>
>
> Mehrdad
>
>
>
>
>
> ᐧ
>
>
>
> On Sun, Apr 28, 2019 at 10:55 AM Micha Silver <tsvibar at gmail.com> wrote:
>
>
>
> On 27/04/2019 22:05, Mehrdad Varedi wrote:
>
>
> Hi Everyone,
>
> I have detail explanations of connecting to an existing dataset in GRASS
> from R in this address:
> https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7
>
>
>
> 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?
>
>
>
> 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
>
>
>
> One other note: you probably will get better suggestions on the R-sig-geo
> list...
>
>
>
> 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.
>
>
>
> Thanks for your help and attention,
>
>
>
> Mehrdad
>
> --
>
> Mehrdad Varedi
>
> ᐧ
>
>
>
> _______________________________________________
>
> grass-user mailing list
>
> grass-user at lists.osgeo.org
>
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
> --
>
> Micha Silver
>
> Ben Gurion Univ.
>
> Sde Boker, Remote Sensing Lab
>
> cell: +972-523-665918
>
>
>
>
> --
>
> Mehrdad Varedi
>
--
Mehrdad Varedi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20190429/8777a515/attachment.html>
More information about the grass-user
mailing list