Hello, I would suggest to use v.what.rast with multiple runs - one for each of the raster maps. It's more simple than passing around coordinate pairs. Or if other sampling strategies are required (i.e. with bilinear interpolation), the v.sample is the right tool.
Maris. http://grass.osgeo.org/grass64/manuals/html64_user/v.what.rast.html http://grass.osgeo.org/grass64/manuals/html64_user/v.sample.html 2012. gada 23. marts 18:39 Margherita Di Leo <[email protected]> rakstīja: > Hi, > > On Fri, Mar 23, 2012 at 5:06 PM, <[email protected]> wrote: >> >> Hello, >> I wonder if there is a way to extract/sample (eg using nearest neighbour) >> the values from multiple rasters that correspond to a set of to vector >> points into a table. >> I could find a way to do this for one raster, but not for multiple >> rasters. Has anyone done this in GRASS? > > > Not sure if i got what you mean to do. With r.what you can extract the > characteristics from multiple rasters, given the coordinates of the points > you are interested in. If you have multiple points, you can apply r.what > iteratively using a simple script, i.e.: > > #! /usr/bin/python > > import os, sys > from glob import glob > import grass.script as grass > > topidx = sys.argv[1] > accMFD = sys.argv[2] > > fpath = 'your/path/to/coordinates/file' > > # coordinates is a txt file in which coordinates are stored > coord = open( os.path.join(fpath, 'coordinates'), 'r').readlines() > pairs = [] > > for line in coord: > line = line.strip() > x, y = line.split('\t') > pairs.append( x + "," + y ) > > r_what = grass.read_command('r.what', input = 'topidx,accMFD', east_north = > pairs) > > # create a new file output > fout = open( os.path.join(fpath, 'output'), 'w') > fout.write(r_what) > fout.close() > > Hope this helps, > madi > > -- > Ing. Margherita Di Leo, Ph.D. > > _______________________________________________ > grass-user mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/grass-user > _______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
