[R-sig-Geo] RQGIS release 0.2.0

Patrick Schratz patrick.schratz at gmail.com
Sat Jan 21 18:16:10 CET 2017


Dear Ali,

a general note: Please write a new mail if you have a specific problem with
a package instead of replying to the last mail related to the package.

Regarding your issue: I think this error relates to your file and its
missing projection and extent information.

I just tried the code using the RQGIS "dem" dataset and everything worked
fine. Also, I´m not sure if "GRASS_REGION_PARAMETER" and
"GRASS_REGION_CELLSIZE_PARAMETER" need to be set at all or you should
better go with the defaults.

If you want to quickly check the algorithm help you can use
`open_help("grass7:r.neighbors")`.

*library(RQGIS)*
*library(raster)*
*r2 <- data("dem")*

*my_env <- set_env()*

*params <- get_args_man(alg = "grass7:r.neighbors", qgis_env = my_env)*
*params$input  <- dem*
*params$method  <- 2 # "Mode"*
*params$output  <- file.path(tempdir(), "rst_out.tif")*

*out <- run_qgis(alg = "grass7:r.neighbors", params = params, *
*                load_output = params$output, qgis_env = my_env)*
*out*

------

macOS, QGIS 2.18.2, GRASS 7.0

You may also want to post such issues at the Github repository
<https://github.com/jannes-m/RQGIS/issues> or at Stackoverflow/GISexchange
using the tag 'rqgis' in the future.
Issues like this which feature large code blocks and are related to a
specific R package can be much better addressed there than by mail.

Best, Patrick





2017-01-21 15:51 GMT+01:00 Ali Santacruz <amsantac at hotmail.com>:

>
> Awesome work! Thanks a lot!
>
>
> I've been able to run QGIS and SAGA algorithms without issues. However, I
> have some problems running GRASS algorithms,
>
> I'm trying to run r.neighbors from GRASS 7, but the resolution, extent and
> values of the output raster don't match those of the input,
>
>
> Here is the code:
>
>
> # Load raster
> library(raster)
>
> r1 <- raster("pred_m1_3000_recl5.tif")
> r1
>
>
> class       : RasterLayer
> dimensions  : 837, 849, 710613  (nrow, ncol, ncell)
> resolution  : 1, 1  (x, y)
> extent      : 0, 849, -837, 0  (xmin, xmax, ymin, ymax)
> coord. ref. : NA
> data source : E:\amsantac\dstl\working\pred\pred_m1_3000_recl5.tif
> names       : pred_m1_3000_recl5
> values      : 5, 110  (min, max)
>
>
> # Load RQGIS
> library(RQGIS)
> my_env <- set_env("C:/OSGeo4W64/")
> dir_tmp <- tempdir()
>
>
> # Set parameters for grass7:r.neighbors
> params <- get_args_man(alg = "grass7:r.neighbors", qgis_env = my_env)
> params$input  <- r1
> params$method  <- 2 # "Mode"
> params$output  <- file.path(dir_tmp, "rst_out.tif")
>
> params$GRASS_REGION_PARAMETER <- "0,849,-837,0"    # as xmin, xmax, ymin,
> ymax
> params$GRASS_REGION_CELLSIZE_PARAMETER <- "1.0"
>
> out <- run_qgis(alg = "grass7:r.neighbors", params = params, load_output =
> params$output, qgis_env = my_env)
> out
>
>
> class       : RasterLayer
> dimensions  : 1, 7, 7  (nrow, ncol, ncell)
> resolution  : 0.1519435, 1  (x, y)
> extent      : 0, 1.063604, 0, 1  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84
> +towgs84=0,0,0
> data source : C:\Users\Guest\AppData\Local\Temp\RtmpwJu31Y\rst_out.tif
> names       : rst_out
>
>
>
> Note the output only has 1 row, 7 cols (vs. 837 rows, 849 cols in input).
> The CRS has been set as long-lat, while the CRS is NA in the input,
>
>
> Also note that the resolution has been changed from 1 to 0.1519,
>
>
> I wonder if there is an issue on how the params$GRASS_REGION_PARAMETER is
> defined. I have tried different ways eg., "0,849,-837,0" (as xmin, xmax,
> ymin, ymax), "0,-837,849,0" (as xmin, ymin, xmax, ymax), extent(r1) (which
> gives error).
>
>
> The input image (550 kb) can be downloaded from this link:
> https://www.dropbox.com/s/do95t48foepw62e/pred_m1_3000_recl5.tif?dl=0
>
>
>
> Thanks for your help,
>
>
> Best regards,
>
>
> Ali
>
>
>
> sessionInfo()
>
>
> R version 3.3.2 (2016-10-31)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows >= 8 x64 (build 9200)
>
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252    LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C                           LC_TIME=English_United
> States.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] RQGIS_0.2.0.9000     raster_2.5-8         sp_1.2-3
>  RevoUtilsMath_10.0.0
>
> loaded via a namespace (and not attached):
> [1] RevoUtils_10.0.2 rgdal_1.1-10     tools_3.3.2      Rcpp_0.12.7
> grid_3.3.2       lattice_0.20-34
>
>
> ________________________________
> De: R-sig-Geo <r-sig-geo-bounces at r-project.org> en nombre de "Jannes
> Münchow" <malNamalJa at gmx.de>
> Enviado: jueves, 19 de enero de 2017 06:31:34 a. m.
> Para: r-sig-geo at r-project.org
> Asunto: [R-sig-Geo] RQGIS release 0.2.0
>
> Dear list members,
>
> today we are happy to announce a new version of RQGIS! RQGIS establishes
> an interface between R and QGIS, i.e. it allows the user to access the more
> than 1000 QGIS geoalgorithms from within R. The most important news is that
> you can run again the most recent QGIS releases (>=2.18.2) with RQGIS
> without having to modify Python source code. This modification became
> necessary due to a bug introduced in QGIS 2.16 (see
> https://github.com/jannes-m/RQGIS#rqgis-modifications-v-216-2181).
>
> [https://avatars0.githubusercontent.com/u/9986952?v=3&s=400]<https://
> github.com/jannes-m/RQGIS#rqgis-modifications-v-216-2181>
>
> GitHub - jannes-m/RQGIS: RQGIS - integrating R with QGIS<
> https://github.com/jannes-m/RQGIS#rqgis-modifications-v-216-2181>
> github.com
> RQGIS - integrating R with QGIS ... Now that we have a spatial object, we
> can move on to using RQGIS. First of all, we need to specify all the paths
> necessary to run ...
>
>
>
>
> This release fixes also several bugs which we detected thanks to user
> feedback. To learn more about these, please refer to
> https://github.com/jannes-m/RQGIS/releases/tag/v0.2.0.
>
> [https://avatars0.githubusercontent.com/u/9986952?v=3&s=400]<https://
> github.com/jannes-m/RQGIS/releases/tag/v0.2.0>
>
> jannes-m/RQGIS<https://github.com/jannes-m/RQGIS/releases/tag/v0.2.0>
> github.com
> RQGIS - integrating R with QGIS
>
>
>
>
> For more information on RQGIS, how to install it and examples how to use
> RQGIS, please refer to https://github.com/jannes-m/RQGIS and my
> https://jannesm.wordpress.com/category/r/.
>
> Posts about R on jannesm<https://jannesm.wordpress.com/category/r/>
> jannesm.wordpress.com
> Posts about R written by jannesm
>
>
>
> [https://avatars0.githubusercontent.com/u/9986952?v=3&s=400]<https://
> github.com/jannes-m/RQGIS>
>
> GitHub - jannes-m/RQGIS: RQGIS - integrating R with QGIS<
> https://github.com/jannes-m/RQGIS>
> github.com
> RQGIS - integrating R with QGIS ... Now that we have a spatial object, we
> can move on to using RQGIS. First of all, we need to specify all the paths
> necessary to run ...
>
>
>
>
> All the best,
>
> Jannes
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> R-sig-Geo Info Page - ETH Zurich<https://stat.ethz.ch/
> mailman/listinfo/r-sig-geo>
> stat.ethz.ch
> R-sig-Geo -- R Special Interest Group on using Geographical data and
> Mapping About R-sig-Geo
>
>
>
>
>         [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list