<div dir="ltr">If you are using the latest version, you should have an example R script called Advanced raster histogram, with the following code<div><br></div><div><p style="margin:0px">##Classification=group</p>
<p style="margin:0px">##Layer = raster|R.raster</p>
<p style="margin:0px">##no_data_value = number 0</p>
<p style="margin:0px">##showplots</p>
<p style="margin:0px">Layer <- raster(Layer, 1)</p>
<p style="margin:0px">NAvalue(Layer) = no_data_value</p>
<p style="margin:0px">hist(as.matrix(Layer), breaks=100, xlab = basename(filename(Layer)))</p><p style="margin:0px"><br></p><p style="margin:0px">It uses the raster package</p><p style="margin:0px"><br></p><p style="margin:0px">
What do you think of this solution? Leaving the current types "raster" and "vector", which create the object in R, and then two additional ones "rasterfile" and "vectorfile", that create the same interface but skip the process of creating the obejct and pass the filename string to R. That woul be more flexible, and not to complex.</p>
<p style="margin:0px"><br></p><p style="margin:0px">For the latest docs, have a look at the QGIS doc repo: <a href="http://github.com/qgis/QGIS-Documentation/tree/master/source/docs/user_manual/sextante">http://github.com/qgis/QGIS-Documentation/tree/master/source/docs/user_manual/sextante</a></p>
<p style="margin:0px"><br></p><p style="margin:0px">Regards</p><p style="margin:0px">Victor</p></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/2/22 Matteo Mattiuzzi <span dir="ltr"><<a href="mailto:matteo@mattiuzzi.com" target="_blank">matteo@mattiuzzi.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sounds great!<div>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.</div>

<div><br></div><div>to load a raster-file it has 3 function:</div><div>raster # used for single layer raster data</div><div>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</div>

<div>brick # used for a multi-layer image (tipically BIP, BIL)</div><div># 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. </div>

<div><br></div><div>to write a raster file:</div><div>writeRaster</div><div>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.<br>

</div><div><br></div><div>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.</div>

<div>shapefile # uses readOGR/writeOGR and can handle only ESRI shapefiles....</div><div><br></div><div>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.</div>

<div>I have tried:<br></div><div><span style="font-family:arial,sans-serif;font-size:13px">##myraster=raster|R.Raster</span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">and also </span><br>
</div><div><div><span style="font-family:arial,sans-serif;font-size:13px">##myraster=raster|R.raster</span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">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...</span><br>

</div></div><div><span style="font-family:arial,sans-serif;font-size:13px"> </span><br></div><div>Thanks! </div><span class="HOEnZb"><font color="#888888"><div>Matteo</div><div><br></div><div><br></div><div>     </div><div>
<br></div>
</font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2013/2/22 Victor Olaya <span dir="ltr"><<a href="mailto:volayaf@gmail.com" target="_blank">volayaf@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Matteo<div><br></div><div>Thanks for your ideas</div><div><br></div><div>you can tell SEXTANTE to use the raster package by using</div><div><br></div><div>##myraster=raster|R.Raster</div>
<div><br></div><div>instead of </div><div><br></div><div>##myraster=raster<br></div><div><br></div><div>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.</div>


<div><br></div><div>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.</div>


<div><br></div><div>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.</div>


<div><br></div><div>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</div><div><br></div><div>Many thanks again for your help</div>


<div><br></div><div>Victor</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/2/22 Matteo Mattiuzzi <span dir="ltr"><<a href="mailto:matteo@mattiuzzi.com" target="_blank">matteo@mattiuzzi.com</a>></span><br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Dear list,<div><br></div><div>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!</div>



<div><br></div><div>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!</div>



<div>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.</div><div>Thanks Matteo</div>



<div><br></div><div>here an example for extracting and plotting pixels based on vector, point or polygon shp file:</div><div><br></div><div><div>##[MyScr]=group</div><div>##vector=vector</div><div>
##raster=raster</div><div>library(raster)</div><div><br></div><div>s <- shapefile(vector) % high level function from raster package, the argument should be only the file path+ name</div><div>r <- brick(raster) % high level function from raster package, the argument should be only the file path+ name</div>



<div><br></div><div>v <- extract(r,s)</div><div>##showplots</div><div>for(u in seq_along(v))</div><div>{</div><div>    val <- v[[u]]</div><div>    if(u>1) X11()</div><div>    </div><div>    plot(x=1:ncol(val),ylim=c(min(val),max(val)),type="n",main=paste("Extraction line",u),xlab="Band",ylab="Spectral")</div>



<div><br></div><div>    for(i in 1:nrow(val))</div><div>    {</div><div>       lines(val[i,],col=i)</div><div>    }</div><div>}</div><div><br></div><div>############################</div></div><div>LINUX Ubuntu 12.10</div>



<div><span style="border-spacing:0px;border-collapse:separate;font-size:medium;font-family:Times"><table width="100%"><tbody><tr><td>QGIS version</td><td>1.9.0-Master</td><td>QGIS code revision</td>
<td>2a2465e</td></tr><tr><td>Compiled against Qt</td><td>4.8.1</td><td>Running against Qt</td><td>4.8.1</td></tr><tr><td>Compiled against GDAL/OGR</td><td>1.9.2</td><td>Running against GDAL/OGR</td><td>1.9.2</td></tr><tr>



<td>GEOS Version</td><td>3.3.3</td><td>PostgreSQL Client Version</td><td>9.1.8</td></tr><tr><td>SpatiaLite Version</td><td>3.1.0-RC2</td><td>QWT Version</td><td>5.2.2</td></tr><tr><td>PROJ.4 Version</td><td>480</td><td>QScintilla2 Version</td>



<td></td></tr><tr><td colspan="4">This copy of QGIS writes debugging output.<br></td><td colspan="4"><br>R version 2.15.2 (2012-10-26) -- "Trick or Treat"<br><br></td></tr></tbody></table></span></div></div>
<br></div></div>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>