Closed BastienFR closed 5 years ago
Running the grass7:v.generalize
geoalgorithm in the QGIS GUI also tells me that there is no output, so I guess this might be the problem.
However, the buffer function works for me:
library("sf")
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
library("RQGIS3")
#> Loading required package: reticulate
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"
data("random_points")
params = get_args_man("grass7:v.buffer")
#> Choosing default values for following parameters:
#> type: 0
#> GRASS_OUTPUT_TYPE_PARAMETER: 0
#> See get_options('grass7:v.buffer') for all available options.
params$input = random_points
params$distance = 100
params$output = file.path(tempdir(), "buf.shp")
out = run_qgis("grass7:v.buffer", params = params, load_output = TRUE)
#> $output
#> [1] "C:/Users/janne/AppData/Local/Temp/Rtmp2VWOH7/buf.shp"
plot(st_geometry(out))
Created on 2019-04-23 by the reprex package (v0.2.1)
Hello, sorry to reopenned that but I really think it's a bug. Trying your v.buffer
example and playing around I've found to that the only way to get my code to work is to add a qgis_session_info()
call before it:
So, lets start with the fail example. The basic v.generalise
, alone fails:
#Restarting R session...
library("RQGIS3")
library("raster")
library("rgdal")
# download German administrative areas
ger = getData(name = "GADM", country = "DEU", level = 1)
ger = spTransform(ger, CRS("+proj=cass +lat_0=52.41864827777778 +lon_0=13.62720366666667 +x_0=40000 +y_0=10000 +ellps=bessel +datum=potsdam +units=m +no_defs "))
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"
#get_usage(alg = "grass7:v.generalize")
#get_args_man(alg = "grass7:v.generalize")
out = run_qgis(alg = "grass7:v.generalize",
input=ger,
output = "d:/temp/test_simple_grass.shp",
error = "d:/temp/test_simple_grass_error.shp",
threshold = "1",
load_output = TRUE)
Error in py_call_impl(callable, dots$args, dots$keywords) :
QgsProcessingException: There were errors executing the algorithm.
However, if I add the qgis_session_info()
before my v.generalize
, it work:
qgis_session_info()
#$`gdal`
#[1] "2.4.1"
#$grass7
#[1] FALSE
#$qgis_version
#[1] "3.4.6-Madeira"
#$saga
#[1] "2.3.2"
out = run_qgis(alg = "grass7:v.generalize",
input=ger,
output = "d:/temp/test_simple_grass.shp",
error = "d:/temp/test_simple_grass_error.shp",
threshold = "1",
load_output = TRUE)
#$`error`
#[1] "d:/temp/test_simple_grass_error.shp"
#$output
#[1] "d:/temp/test_simple_grass.shp"
I thought that the set_env("C:/OSGeo4W64")
was the one preparing the session and that qgis_session_info()
was only used to get information on that session, but it seems qgis_session_info()
is actually starting something useful for the code. Is it normal? If it's the case, it should be stated in your tutorial.
I was a user of
RQGIS
but just started usingRQGIS3
. I've been having problem using the GRASS process. In this example, I usegrass7:v.generalize
but I also triedgrass7:v.buffer
with the same error.RE:
gives me:
I can run
grass7:v.generalize
no problem directly in QGIS. Is it a bug or it's only on my side?I just updated my OSGEO4W, however I'm confuse which version of QGIS it's using on my computer. I have: 2.18.16, 2.18.23, 3.4.6, 3.6.1, 3.7.0.
my
sessioninfo
: