I am using Grass7 and Ubuntu14.4
I am attempting to carry out a geographically weighted regression between two .tif files but am having issues with the call to r.gwr
Code and output is as follows. Apologies this is super long but shows the process:
>library(spgrass7)
>library(rgrass7)
>library(raster)
# the two rasters for comparison
>check_alt <- raster("alt_ti.tif")
>check_tmin <- brick("tmin_ti.tif")
>initGRASS(gisBase = "/usr/lib/grass70", home = tempdir(), override = TRUE)
gisdbase /tmp/RtmpLkDG6G
location file2a6639741baf
mapset file2a6678af1328
rows 1
columns 1
north 1
south 0
west 0
east 1
nsres 1
ewres 1
projection NA
>execGRASS("r.in.gdal", flags = c("e", "o", "quiet"),
+parameters = list(input = paste0(data_path, "alt_ti.tif"), output = "alt"))
WARNING: Over-riding projection check
Warning message:
In execGRASS("r.in.gdal", flags = c("e", "o", "quiet"), parameters = list(input = paste0(data_path, :
The command:
r.in.gdal -e -o --quiet input=/run/user/1001/gvfs/smb-share:server=sdgrp1,share=users/Public/Data_products/tmin_ti.tif output=tmin
produced at least one warning during execution:
WARNING: Over-riding projection check
# Set proper g.region
>execGRASS("g.region", parameters = list(raster = "alt"))
>execGRASS("r.in.gdal", flags = c("e", "o", "quiet"),
parameters = list(input = paste0(data_path, "tmin_ti.tif"),
output = "tmin"))
Warning message:
In execGRASS("r.in.gdal", flags = c("e", "o", "quiet"), parameters = list(input = paste0(data_path, :
The command:
r.in.gdal -e -o --quiet input=/run/user/1001/gvfs/smb-share:server=sdgrp1,share=users/austin.haffenden/Public/Data_products/tmin_ti.tif output=tmin
produced at least one warning during execution:
WARNING: Over-riding projection check
# run the gwr
>execGRASS("r.gwr", flags = c("e"),
parameters = list(mapx = "alt", mapy = "tmin", bandwidth = 10,
kernel = "gauss",
output = "lapse"))
Error in parseGRASS(cmd, legacyExec = legacyExec) : The command
r.gwr --interface-description
could not be run (127), and produced the error message:
sh: 1: r.gwr: not found
# install r.gwr addon using g.extension
>execGRASS("g.extension", extension = "r.gwr")
WARNING: GRASS_ADDON_BASE is not defined, installing to ~/.grass7/addons
Fetching <r.gwr> from GRASS-Addons SVN repository (be patient)...
Compiling...
main.c: In function ‘main’:
main.c:42:32: warning: variable ‘t’ set but not used [-Wunused-but-set-variable]
double Rsq, Rsqadj, SE, F, t, AIC, AICc, BIC;
^
main.c:42:25: warning: variable ‘SE’ set but not used [-Wunused-but-set-variable]
double Rsq, Rsqadj, SE, F, t, AIC, AICc, BIC;
^
Installing...
Updating addons metadata file...
Installation of <r.gwr> successfully finished
WARNING: This add-on module will not function until you set the
GRASS_ADDON_BASE environment variable (see "g.manual variables")
Warning message:
In execGRASS("g.extension", extension = "r.gwr") : The command:
g.extension extension=r.gwr operation=add
produced at least one warning during execution:
WARNING: GRASS_ADDON_BASE is not defined, installing to ~/.grass7/addons
WARNING: Extension <r.gwr> already installed. Re-installing...
Fetching <r.gwr> from GRASS-Addons SVN repository (be patient)...
Compiling...
main.c: In function ‘main’:
main.c:42:32: warning: variable ‘t’ set but not used [-Wunused-but-set-variable]
double Rsq, Rsqadj, SE, F, t, AIC, AICc, BIC;
^
main.c:42:25: warning: variable ‘SE’ set but not used [-Wunused-but-set-variable]
double Rsq, Rsqadj, SE, F, t, AIC, AICc, BIC;
^
Installing...
Updating addons metadata file...
Installation of <r.gwr> successfully finished
WARNING: This add-on module will not function until you set the
GRASS_ADDON_BASE environment variable (see "g.manual variables")
# set the variable GRASS_ADDON_BASE to the location where the addon was installed: ~/.grass7/addons
execGRASS("g.gisenv", set = "GRASS_ADDON_BASE = ~/.grass7/addons")
# check that the variable has been set
execGRASS("g.gisenv", get = "GRASS_ADDON_BASE")
~/.grass7/addons
Warning message:
In readLines(outFile) :
incomplete final line found on '/tmp/RtmpLkDG6G/file2a663251b90b.out'
# Run the gwr again
execGRASS("r.gwr", flags = c("e"),
parameters = list(mapx = "alt", mapy = "tmin", bandwidth = 10,
kernel = "gauss",
output = "lapse"))
Error in parseGRASS(cmd, legacyExec = legacyExec) : The command
r.gwr --interface-description
could not be run (127), and produced the error message:
sh: 1: r.gwr: not found
Which is where I am at. I have attempted to go in through the graphical front-end and check this variable under gksudo and get the problem detailed here:
https://gis.stackexchange.com/questions/182349/grass-on-ubuntu-error-variable-location-name-not-set
I can check the variable in the gui under sudo, it isn't set. I can also set it but it doesn't stick. My understanding is that it is more correct to use gksudo for gui. I am hoping that the solution to one problem may be to both.