[GRASS-user] Using g.extension in with rgrass7 in R

Hello,

I’m trying to use GRASS in RStudio using the ‘rgrass7’ pacakge.

So far I have:

library(rgrass7)

initGRASS(gisBase = “C:/OSGeo4W64/apps/grass/grass-7.3.svn”,
gisDbase = “C:/Sandbox/RGRASS/”,
location = “TEST”, mapset = “MAP1”,override=TRUE)

in.rast ← “C:/Users/James/Desktop/15m_site2/subset_output/15m_site2_subset_ortho.tif”

execGRASS(“r.in.gdal”, flags=“o”, parameters=list(input=in.rast, output=“ortho”))

Which works fine!

However, when I want to install an extension with:

execGRASS(“g.extension”, parameters=list(extension=“i.segment.uspo”, operation=“add”))

I get the following error:

Downloading precompiled GRASS Addons <i.segment.uspo>…
ERROR: Variable ‘LOCATION_NAME’ not set
ERROR: Variable ‘LOCATION_NAME’ not set
ERROR: Variable ‘LOCATION_NAME’ not set
Traceback (most recent call last):
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 1737, in
sys.exit(main())
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 1716, in main
install_extension(source=source, url=url, xmlurl=xmlurl)
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 702, in install_extension
blist = install_extension_xml(xmlurl, mlist)
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 922, in install_extension_xml
write_xml_modules(xml_file, tree)
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 601, in write_xml_modules
libgis_revison = grass.version()[‘libgis_revision’]
KeyError: ‘libgis_revision’
Warning message:
running command ‘g.extension.bat extension=i.segment.uspo operation=add’ had status 1

Can anyone tell me where I have to set the ‘LOCATION_NAME’ please?

Kind regards

James

···

James Duffy
PhD Researcher
Environment and Sustainability Institute
Penryn Campus
University of Exeter
Penryn
Cornwall
TR10 9FE

Solved.

I found that closing RStudio and then installing GRASS extensions, and reopening RStudio afterwards solved the issue. Solution described here.

---------- Forwarded message ----------
From: James Duffy <james.philip.duffy@gmail.com>
Date: 3 May 2017 at 14:44
Subject: Using g.extension in with rgrass7 in R
To: grass-user <grass-user@lists.osgeo.org>

Hello,

I’m trying to use GRASS in RStudio using the ‘rgrass7’ pacakge.

So far I have:

library(rgrass7)

initGRASS(gisBase = “C:/OSGeo4W64/apps/grass/grass-7.3.svn”,
gisDbase = “C:/Sandbox/RGRASS/”,
location = “TEST”, mapset = “MAP1”,override=TRUE)

in.rast ← “C:/Users/James/Desktop/15m_site2/subset_output/15m_site2_subset_ortho.tif”

execGRASS(“r.in.gdal”, flags=“o”, parameters=list(input=in.rast, output=“ortho”))

Which works fine!

However, when I want to install an extension with:

execGRASS(“g.extension”, parameters=list(extension=“i.segment.uspo”, operation=“add”))

I get the following error:

Downloading precompiled GRASS Addons <i.segment.uspo>…
ERROR: Variable ‘LOCATION_NAME’ not set
ERROR: Variable ‘LOCATION_NAME’ not set
ERROR: Variable ‘LOCATION_NAME’ not set
Traceback (most recent call last):
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 1737, in
sys.exit(main())
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 1716, in main
install_extension(source=source, url=url, xmlurl=xmlurl)
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 702, in install_extension
blist = install_extension_xml(xmlurl, mlist)
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 922, in install_extension_xml
write_xml_modules(xml_file, tree)
File “C:/OSGeo4W64/apps/grass/grass-7.3.svn/scripts/g.extension.py”, line 601, in write_xml_modules
libgis_revison = grass.version()[‘libgis_revision’]
KeyError: ‘libgis_revision’
Warning message:
running command ‘g.extension.bat extension=i.segment.uspo operation=add’ had status 1

Can anyone tell me where I have to set the ‘LOCATION_NAME’ please?

Kind regards

James

James Duffy
PhD Researcher
Environment and Sustainability Institute
Penryn Campus
University of Exeter
Penryn
Cornwall
TR10 9FE

James Duffy
PhD Researcher
Environment and Sustainability Institute
Penryn Campus
University of Exeter
Penryn
Cornwall
TR10 9FE