[GRASS-stats] raster data in R
Rainer M Krug
Rainer at krugs.de
Fri Sep 11 01:50:21 PDT 2015
Marisa Donnelly <madonnelly at ucdavis.edu> writes:
> Hi Rainer,
> This clarifies things a great deal. I'll try it and let you know, but it
> makes sense so I don't anticipate needing an example.
> Thank you!
Pleasure
Just check out
?"SpatialGridDataFrame-class"
in R and you find the info about the object returned by readfRAST().
Among other info, it states:
,----
| Slots:
|
| ‘grid’: see GridTopology-class; grid parameters
|
| ‘bbox’: Object of class ‘"matrix"’; bounding box
|
| ‘proj4string’: Object of class ‘"CRS"’; projection
|
| ‘data’: Object of class data.frame, containing attribute data
`----
Cheers,
Rainer
> Marisa
>
> On Thu, Sep 10, 2015 at 8:22 PM, Rainer M Krug <r.m.krug at gmail.com> wrote:
>
>>
>>
>> Envoyé de mon iPhone
>>
>> > Le 10 sept. 2015 à 16:47, Markus Neteler <neteler at osgeo.org> a écrit :
>> >
>> > Hi Rainer,
>> >
>> >> On Thu, Sep 10, 2015 at 4:36 PM, Rainer M Krug <Rainer at krugs.de> wrote:
>> >> ...
>> >> Just check out the rgrass7 package - readRAST() allows you to read your
>> >> raster, then you do your calculations with the data,
>> >
>> > ... this calculation part is the question of Marisa... any recommended
>> > tutorials on how to loop over pixels in R after having used
>> > readRAST()?
>>
>> The data slot of the returned SpatialGridDataFrame is simply a data.frame
>> with one cell per row. So you can simply iterate over each row and add the
>> results as a new column, which you can then save. If the function is
>> vectorizes, you don't even have to iterate but R can do the work. If
>> necessary, I can send you a small example tomorrow- just let me know.
>>
>> Hope this helps,
>>
>> Rainer
>>
>> >
>> >> then you add them
>> >> to the map object in R and finally you can safe them by using
>> >> writeRAST() back to GRASS.
>> >
>> > Yes, that part is clear. Just the "loop" best practice not so much.
>> >
>> > thanks
>> > 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 : +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: Rainer at krugs.de
Skype: RMkrug
PGP: 0x0F52F982
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 480 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-stats/attachments/20150911/02e13098/attachment.pgp>
More information about the grass-stats
mailing list