Skip to content

extract values to points

3 messages · Frauke Barthold, Alexander Brenning, Paul Hiemstra

#
Hi Frauke,

in the RSAGA package there is a function pick.from.ascii.grid which does
exactly what you want. Even works with large grids as it can process
them row by row. I use it for extracting point data from stacks of
Landsat bands, terrain attributes etc.

Here a case study (landslide susceptibility modeling):

http://www.environment.uwaterloo.ca/u/brenning/Brenning-2008-RSAGA.html

also available as pdf:
http://www.environment.uwaterloo.ca/u/brenning/Brenning-2008-RSAGA.pdf

I hope this helps

Cheers
    Alex
Frauke Barthold wrote:

  
    
4 days later
#
Hi,

An option using only R is to use the overlay() command from the sp 
package, try running this example:

# Load data
library(sp)
data(meuse)
# point data
coordinates(meuse) = ~x+y
data(meuse.grid)
# grid data
gridded(meuse.grid) = ~x+y

overlay(meuse.grid, meuse)
# Returns the indices in meuse.grid correpsonding to the points in meuse
# get the data from meuse.grid, for example the column "dist"
# a non spatial vector
dist = meuse.grid$dist[overlay(meuse.grid, meuse)]
# A spatialPointsDataFrame
dist = meuse.grid[overlay(meuse.grid, meuse), "dist"]

Also check out the rgdal pacakge to get your data into R-spatial objects.

cheers,
Paul
Frauke Barthold wrote: