[Qgis-developer] QGIS - SEXTANTE - R

Matteo Mattiuzzi matteo at mattiuzzi.com
Fri Feb 22 07:57:40 PST 2013


Sounds great!
I could imagine to have a default method (for raster/vector) to facilitate
the transfer of the data into R. I think rgdal is a quite low-level package
that is also used by the raster package. I think that at least for raster
data the package raster is the most advanced and most user-friendly package
at all and also the most diffused in the community.

to load a raster-file it has 3 function:
raster # used for single layer raster data
stack # used for multiple single- or multi-layer files loaded as 1
multilayer file (requires identical extent, proj and resolution for all
files), comparable with a BSQ file with separate sources
brick # used for a multi-layer image (tipically BIP, BIL)
# the problem could be here that the user has to know in advanced which one
to use. In most of the cases its fairly simple, or the function stack()
could handle every input, but I'm not sure it it is the best solution.

to write a raster file:
writeRaster
Normally the raster package writes everything to a tmp folder, writeRaster
is basically the function to move the file from the tmp to a definitive
location handing datatype, filename, driver etc.

For reading and writing vector data it presents some limited facilities,
but very simple to use, could also be suitable as a default method, and if
required it will be easy to amplify its functionality.
shapefile # uses readOGR/writeOGR and can handle only ESRI shapefiles....

>From my point of view I could imagine to have such default, but I think it
has to be easy to modify (as you wrote me!). I will try to mobilitate some
R-SIG-GEO members for this discussion.
I have tried:
##myraster=raster|R.Raster
and also
##myraster=raster|R.raster
but I was not successful. I'm using the developer version from git but I
don't know how to get to the documentation... Actually every time a script
has some non-conform values it disappears from the list...

Thanks!
Matteo






2013/2/22 Victor Olaya <volayaf at gmail.com>

> Matteo
>
> Thanks for your ideas
>
> you can tell SEXTANTE to use the raster package by using
>
> ##myraster=raster|R.Raster
>
> instead of
>
> ##myraster=raster
>
> This is already documented, but only in the github version of the
> documentation, as it is something that is implemented only in the
> development versino of SEXTANTE.
>
> Anyway, your proposal seems interesting. I tried to save all the possible
> effort from users developing R algorithms in SEXTANTE, but it's true that
> you will have more flexibility by just getting the filename.
>
> Honestly, I am not an R expert, so I will implement whatever you the R
> users think is best. My goal is to make it easier for anyonen with a good
> knowledge of R to adapt their algorithms to SEXTANTE and be able to call
> them from QGIS. I am opne to all kind off suggestions, since, as I said, I
> am not an R user and my knowledge of R is very limited.
>
> Let's discuss this here in the list.. Hopefully other people using R and
> SEXTANTE will give their opinion and we can decide what to do
>
> Many thanks again for your help
>
> Victor
>
>
>
>
> 2013/2/22 Matteo Mattiuzzi <matteo at mattiuzzi.com>
>
>> Dear list,
>>
>> I have now tested the possibilities to integrate R Processing in Q-GIS. I
>> think it closes the huge gap in R of interactive visualization and also
>> gives the possibility to use R-functionality to non-R people!
>>
>> I saw that a raster/vector file is loaded through rgdal and there is no
>> possibility to do it in the own way, such as the almost standard 'raster'
>> package that handles also out of RAM data!
>> In order to maintain the flexibility of R I think that arguments should
>> be passed as they are (path+file) and everybody would be free to benefit
>> from the entire R repository of functions.
>> Thanks Matteo
>>
>> here an example for extracting and plotting pixels based on vector, point
>> or polygon shp file:
>>
>> ##[MyScr]=group
>> ##vector=vector
>> ##raster=raster
>> library(raster)
>>
>> s <- shapefile(vector) % high level function from raster package, the
>> argument should be only the file path+ name
>> r <- brick(raster) % high level function from raster package, the
>> argument should be only the file path+ name
>>
>> v <- extract(r,s)
>> ##showplots
>> for(u in seq_along(v))
>> {
>>     val <- v[[u]]
>>     if(u>1) X11()
>>
>>
>> plot(x=1:ncol(val),ylim=c(min(val),max(val)),type="n",main=paste("Extraction
>> line",u),xlab="Band",ylab="Spectral")
>>
>>     for(i in 1:nrow(val))
>>     {
>>        lines(val[i,],col=i)
>>     }
>> }
>>
>> ############################
>> LINUX Ubuntu 12.10
>> QGIS version1.9.0-MasterQGIS code revision 2a2465eCompiled against Qt
>> 4.8.1Running against Qt4.8.1Compiled against GDAL/OGR1.9.2Running
>> against GDAL/OGR1.9.2 GEOS Version3.3.3PostgreSQL Client Version9.1.8SpatiaLite
>> Version3.1.0-RC2QWT Version5.2.2PROJ.4 Version480QScintilla2 Version This
>> copy of QGIS writes debugging output.
>>
>> R version 2.15.2 (2012-10-26) -- "Trick or Treat"
>>
>>
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130222/e484c45b/attachment.html>


More information about the Qgis-developer mailing list