[GRASS-user] Creating an R Container with GRASS support

,

Hi everybody,
my hope is to reference the necessary files and folders or copy them on an R image to use GRASS functions in R.

I have a Docker file like the following:

FROM neteler/grassgis7 as thegrass

FROM rocker/rstudio

COPY --from=thegrass /usr/local/grass79 /usr/local/grass79

COPY --from=thegrass /data /data

COPY --from=thegrass /home/grass /home/grass

RUN sudo apt-get install -y libcurl4-openssl-dev libxml2-dev

Then I build and run the image which has a few folders from GRASS GIS
In RStudio, I install and call the “rgrass7” and “raster” libraries. (No errors)

Then in Rstudio, I try to run the initGRASS function with the following values:

initGRASS(gisBase = "/usr/local/grass79", home = raster::tmpDir(), gisDbase = "tmpDbase", location = "Kitchener", mapset = "PERMANENT", override = TRUE)

This is the error I recieve:
Error in parseGRASS(cmd, legacyExec = legacyExec) : The command
   g.region --interface-description
could not be run (127), and produced the error message:
   g.region: error while loading shared libraries: libproj.so.12: cannot open shared object file: No such file or directory
In addition: Warning message:
In system2(command = command, args = arguments, stdout = outFile,  :
  error in running command

Do you know a better way to merge the GRASS GIS files with the R image?
Would you please help me to complete the Dockerfile to avoid such errors?

···

Kind regards,

Mehrdad

Mehrdad Varedi, M.A.Sc.

Waterlix Inc. Founder

www.waterlix.com

Cell: +1 (519)722-7057

Hi Mehrdad,

Hi everybody,
my hope is to reference the necessary files and folders or copy them on an R image to use GRASS functions in R.

I have a Docker file like the following:

FROM neteler/grassgis7 as thegrass

FROM rocker/rstudio

COPY --from=thegrass /usr/local/grass79 /usr/local/grass79

Here you only copy (if I am not mistaken) the grass79 folder but not the related system-wide installed PROJ, GDAL etc libs.
They are in /usr/lib[64]/… (don’t know precisely right now).

COPY --from=thegrass /data /data

COPY --from=thegrass /home/grass /home/grass

RUN sudo apt-get install -y libcurl4-openssl-dev libxml2-dev

I suppose you also need to install the geo software stack here as well (see
https://hub.docker.com/r/neteler/grassgis7/dockerfile
)

Then I build and run the image which has a few folders from GRASS GIS
In RStudio, I install and call the “rgrass7” and “raster” libraries. (No errors)

Then in Rstudio, I try to run the initGRASS function with the following values:

initGRASS(gisBase = "/usr/local/grass79", home = raster::tmpDir(), gisDbase = "tmpDbase", location = "Kitchener", mapset = "PERMANENT", override = TRUE)

This is the error I recieve:
Error in parseGRASS(cmd, legacyExec = legacyExec) : The command
   g.region --interface-description
could not be run (127), and produced the error message:
   g.region: error while loading shared libraries: libproj.so.12: cannot open shared object file: No such file or directory

Yes, because it isn’t there yet (see above).

Hope this helps,

Markus

···

Markus Neteler, PhD
https://www.mundialis.de - free data with free software
https://grass.osgeo.org
https://courses.neteler.org/blog

Hi Markus,
I used the Dockerfile you shared and began from the r-base instead of ubuntu, it worked very well. Only, the image is a little big which is more a docker issue.
If you have any recommendations, I would appreciate it, although this is not a GRASS question.

···

Thanks and Kind regards,

Mehrdad

Mehrdad Varedi, M.A.Sc.

Waterlix Inc. Founder

www.waterlix.com

Cell: +1 (519)722-7057

Hi Mehrdad,

On Thu, May 21, 2020 at 2:37 PM Mehrdad Varedi <varedi@waterlix.com> wrote:

Hi Markus,
I used the Dockerfile you shared and began from the r-base instead of ubuntu, it worked very well. Only, the image is a little big which is more a docker issue.
If you have any recommendations, I would appreciate it, although this is not a GRASS question.

Please check our "GRASS GIS docker matrix" at
https://github.com/OSGeo/grass/tree/master/docker

You'll see from that (new) list of base docker images, versions and
included libraries that the Alpine image is way smaller than the
others.
Maybe a choice for you - we switched to Alpine for all our
cloud/docker related activities (that's basically why this image is
there :-).

HTH,
Markus

--
Markus Neteler, PhD
https://www.mundialis.de - free data with free software
https://grass.osgeo.org
https://courses.neteler.org/blog

Thanks, I’ll check them out. :slight_smile:

Mehrdad

On Thu, May 21, 2020, 9:37 AM Markus Neteler, <neteler@osgeo.org> wrote:

Hi Mehrdad,

On Thu, May 21, 2020 at 2:37 PM Mehrdad Varedi <varedi@waterlix.com> wrote:

Hi Markus,
I used the Dockerfile you shared and began from the r-base instead of ubuntu, it worked very well. Only, the image is a little big which is more a docker issue.
If you have any recommendations, I would appreciate it, although this is not a GRASS question.

Please check our “GRASS GIS docker matrix” at
https://github.com/OSGeo/grass/tree/master/docker

You’ll see from that (new) list of base docker images, versions and
included libraries that the Alpine image is way smaller than the
others.
Maybe a choice for you - we switched to Alpine for all our
cloud/docker related activities (that’s basically why this image is
there :-).

HTH,
Markus


Markus Neteler, PhD
https://www.mundialis.de - free data with free software
https://grass.osgeo.org
https://courses.neteler.org/blog