[R-sig-Geo] Re: [GRASSLIST:5390] Script to 'sample' several grids with result saved to text output?

Hamish hamish_nospam at yahoo.com
Tue Jan 18 00:28:43 CET 2005


> I have several rasters with environmental data. I also have point
> data, representing animal locations (collected with GPS collars).
> 
> I would like to use GRASS to 'sample' (apologies for the ArcInfo AML 
> terminology, but it might help people to get what I need) the rasters 
> with the point data and save the results in a text file for further 
> analysis with R.
> 
> The resulting text file should contain a field/attribute of my choice 
> from the points data file (some sort of ID for each point) and a 
> field/attribute for each of the sampled rasters.
> 
> Preferably I would use an R script that calls GRASS, as both point
> data collection and further analysis is done within R. However a GRASS
> script working on input and output text files might also be
> sufficient.



r.what does this nicely:

http://grass.ibiblio.org/grass57/manuals/html57_user/r.what.html


I guess r.what could/should be modified to read from a sites (vector
points) list and write to a new sites (vector points) list with queried
attributes. (currently just pipe from stdin & to stdout)
Easy to do in a script I guess.


Roger:
> If I had figured out how to read the output of r.what into s.in.ascii,
> storing the data as a sites file

I don't think that would be too hard with GRASS 5.7/6:
 v.in.ascii input=r_what_output.txt fs=',' cat=1 x=2 y=3

GRASS 5.0/5.4's s.in.ascii needs to rearrange column order though with
UNIX 'cut' and 'paste' commands first?



Hamish




More information about the R-sig-Geo mailing list