[GRASS-dev] C function which returns raster and additional info?

Rainer M Krug r.m.krug at gmail.com
Wed Oct 19 04:03:18 EDT 2011


On Wed, Oct 19, 2011 at 8:36 AM, Markus Neteler <neteler at osgeo.org> wrote:

> On Tue, Oct 18, 2011 at 10:26 AM, Rainer M Krug <r.m.krug at gmail.com>
> wrote:
> > If this mail has made it already to the lst, I apologise - I just could
> not
> > find it anywhere.
> >
> >
> > Hi
> >
> > I am thinking about the possibility of loading raster directly from GRASS
> > into R, to avoid the overhang of saving to disk and loading again or
> having
> > gdal in between GRASS and R.
> >
> > As R (using the sp package) holds the raster in memory, I was thinking
> about
> > reading the data from GRASS by using a C function, returning the cell
> values
> > and additional info (at least the one provided in  esri ACSII file, i.e.
> > NCOLS, NROWS, XLLCORNER, YLLCORNER, CELLSIZE, NODATA_VALUE) plus
> > geo-referencing info, so that, back in R, this data can be assembled to
> > become a spatial object (SpatialGridDataFrame, as defined in the package
> > sp).
>
> An option may be to
> - open the raster map,
>

What do you mean by "open the raster map)?


> - set computational region to the map
>

Good idea - but it would also be an option to use the active region, to
enable the reading of certain selected regions.


> - read G_get_window()
>
>
> http://grass.osgeo.org/programming6/get__window_8c.html#ada28852284056440f08c032e64a80765
>

Thanks - that's great.
That enables me to get the header date to construct a raster with the same
info in R as a SpatialGrisDataFrame.

Now I would need a function, which reads the cell values and returns it -
either the complete raster, or the by column / row, and then I could
assemble it - any ideas?

Rainer


>
> Markus
>



-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax (F):       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer at krugs.de

Skype:      RMkrug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-dev/attachments/20111019/92a9821b/attachment.html


More information about the grass-dev mailing list