r-spatial / RQGIS3

GNU Lesser General Public License v3.0
69 stars 19 forks source link

GRASS GIS 7 folder is not configured #8

Closed tylerbhampton closed 5 years ago

tylerbhampton commented 5 years ago

I used OSGeo to install the most recent ltr QGIS version and Anaconda to install python. I've had lots of problems getting this example to work and this time I'm getting a python error:

Traceback (most recent call last):
  File "C:/OSGeo4W64/apps/qgis-ltr/python/plugins\processing\algs\grass7\Grass7Algorithm.py", line 383, in processAlgorithm
    self.tr('GRASS GIS 7 folder is not configured. Please '
_core.QgsProcessingException: GRASS GIS 7 folder is not configured. Please configure it before running GRASS GIS 7 algorithms.
 Error in py_call_impl(callable, dots$args, dots$keywords) : 
  QgsProcessingException: There were errors executing the algorithm. 

Full code below:

R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
> library("raster")
Loading required package: sp
> library("rgdal")
rgdal: version: 1.4-3, (SVN revision 828)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
 Path to GDAL shared files: C:/Users/Tyler/Documents/R/win-library/3.6/rgdal/gdal
 GDAL binary built with GEOS: TRUE 
 Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
 Path to PROJ.4 shared files: C:/Users/Tyler/Documents/R/win-library/3.6/rgdal/proj
 Linking to sp version: 1.3-1 
> library("RQGIS3")
Loading required package: reticulate
> set_env("C:/OSGeo4W64")
$root
[1] "C:/OSGeo4W64"

$qgis_prefix_path
[1] "C:/OSGeo4W64/apps/qgis-ltr"

$python_plugins
[1] "C:/OSGeo4W64/apps/qgis-ltr/python/plugins"

> qgis_session_info()
$gdal
[1] "2.4.1"

$grass7
[1] FALSE

$qgis_version
[1] "3.4.6-Madeira"

$saga
[1] "2.3.2"

> py_config()
python:         C:/OSGeo4W64/bin/python3.exe
libpython:      C:/OSGeo4W64/bin/python37.dll
pythonhome:     C:\OSGeo4W64\apps\Python37
version:        3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:\OSGeo4W64\apps\Python37\lib\site-packages\numpy
numpy_version:  1.15.4

NOTE: Python version was forced by use_python function

> #data("dem")
> dem=spDataLarge::elevation
> 
> demfill = run_qgis(alg = "saga:fillsinks",
+                    DEM=dem,
+                    RESULT=file.path(tempdir(), "demfill.sdat"),
+                    load_output = TRUE)
ERROR 4: Unable to open EPSG support file gcs.csv.  Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
$RESULT
[1] "C:/Users/Tyler/AppData/Local/Temp/Rtmpsn7xc7/demfill.sdat"

Warning message:
In check_for_server() :
  Hey there! According to our internal checks, you are trying to run RQGIS3 on a Windows server.
Please note that this is only possible if you imitate a x-display.
QGIS needs this in the background to be able to execute its processing modules.
Note that you need to start the x-display with admin rights
> 
> run_qgis(alg = "grass7:r.watershed",
+          elevation=demfill,
+          #flow=flow,
+          threshold=100,
+          accumulation=file.path(tempdir(), "acc.tif"),
+          drainage=file.path(tempdir(), "flowdir.tif"),
+          load_output = F)
Traceback (most recent call last):
  File "C:/OSGeo4W64/apps/qgis-ltr/python/plugins\processing\algs\grass7\Grass7Algorithm.py", line 383, in processAlgorithm
    self.tr('GRASS GIS 7 folder is not configured. Please '
_core.QgsProcessingException: GRASS GIS 7 folder is not configured. Please configure it before running GRASS GIS 7 algorithms.

 Error in py_call_impl(callable, dots$args, dots$keywords) : 
  QgsProcessingException: There were errors executing the algorithm. 
jannes-m commented 5 years ago

This works for me under Windows:

library("RQGIS3")
#> Loading required package: reticulate
# show session info
qgis_session_info()
#> Trying to find QGIS in C:/OSGEO4~1
#> $gdal
#> [1] "2.4.1"
#> 
#> $grass7
#> [1] FALSE
#> 
#> $qgis_version
#> [1] "3.4.7-Madeira"
#> 
#> $saga
#> [1] "2.3.2"
# fill sinks
run_qgis(alg = "saga:fillsinks",
         DEM = dem,
         RESULT = file.path(tempdir(), "dem_fill.sdat"),
         load_output = FALSE)
#> NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
#> NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
#> NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
#> $RESULT
#> [1] "C:/Users/janne/AppData/Local/Temp/Rtmp8ASjgc/dem_fill.sdat"
# run watershed analysis
out = run_qgis(alg = "grass7:r.watershed",
               elevation = file.path(tempdir(), "dem_fill.sdat"),
               threshold = 100,
               accumulation = file.path(tempdir(), "acc.tif"),
               drainage = file.path(tempdir(), "flowdir.tif"),
               load_output = TRUE)
#> $accumulation
#> [1] "C:/Users/janne/AppData/Local/Temp/Rtmp8ASjgc/acc.tif"
#> 
#> $basin
#> NULL
#> 
#> $drainage
#> [1] "C:/Users/janne/AppData/Local/Temp/Rtmp8ASjgc/flowdir.tif"
#> 
#> $half_basin
#> NULL
#> 
#> $length_slope
#> NULL
#> 
#> $slope_steepness
#> NULL
#> 
#> $spi
#> NULL
#> 
#> $stream
#> NULL
#> 
#> $tci
#> NULL
#> NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
#> NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
out
#> $accumulation
#> class       : RasterLayer 
#> dimensions  : 117, 117, 13689  (nrow, ncol, ncell)
#> resolution  : 30.85, 30.85  (x, y)
#> extent      : 794599.1, 798208.6, 8931775, 8935384  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=utm +zone=17 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : C:/Users/janne/AppData/Local/Temp/Rtmp8ASjgc/acc.tif 
#> names       : acc 
#> attributes  :
#>        ID         min       max redmin redmax greenmin greenmax bluemin
#>  from:  0    67.90281  278.0238      0      0        0        0     255
#>  to  :  9 -5998.18171 -278.0238      0      0        0        0       0
#>  bluemax
#>        0
#>        0
#> 
#> 
#> $drainage
#> class       : RasterLayer 
#> dimensions  : 117, 117, 13689  (nrow, ncol, ncell)
#> resolution  : 30.85, 30.85  (x, y)
#> extent      : 794599.1, 798208.6, 8931775, 8935384  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=utm +zone=17 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : C:/Users/janne/AppData/Local/Temp/Rtmp8ASjgc/flowdir.tif 
#> names       : flowdir 
#> values      : -32768, 32767  (min, max)
#> attributes  :
#>  ID min max redmin redmax greenmin greenmax bluemin bluemax
#>   0   0   8    255      0      255        0     255       0
#>   1  -8   0      0    255        0      255       0     255

Created on 2019-05-14 by the reprex package (v0.2.1)

Please note that you are not using the latest QGIS LTR which is 3.4.7. I don't know what you mean that you use Anaconda Python. QGIS ships with its own Python binary under Windows and this is what your output is also saying (C:/OSGeo4W64/bin/python3.exe). Please make also sure that your OSGeo installation also installed GRASS GIS.

tylerbhampton commented 5 years ago

Jannes thanks so much again for your help. Yes, I reinstalled OSGeo, with latest QGIS LTR 3.4.7 and python3 and GRASS GIS. Worked great. It seems the problems I've been having are with the OSGeo installer, since you have to manually configure the custom install. Do you have a list somewhere of all the required components needed to properly have your package work?

jannes-m commented 5 years ago

To rewrite the installation_guide vignette is on my to-do list!