Skip to content

Raster to points

4 messages · celso at stephan.mus.br, S. Koukoulas (lists), Tim Appelhans +1 more

#
Hi!

I need to create a new attribute for points in a shapefile containing 
values from a raster (originally a kernel) on corresponding position. Does
anyone has a clue?

Thanks!!

Celso Stephan
#
I am not aware of a function in R but you could use Grass (either as
stand alone or perhaps through the spgrass6 library in R - you need to
have your data in a GRASS location/mapset first) :

v.what.rast  in GRASS (http://www.osgeo.org/grass - open source)

or try the <point sampling tool>  in QGIS which is a plugin from
contributed repository and you need to install it first from <fetch
plugins>. In the second tab tick box <add 3rd party plugins> (qgis.org -
open source)

sotiris
On 20/04/12 19:40, celso at stephan.mus.br wrote:
#
The 'over' function in the sp package should do what you are after.
Cheers
Tim
On 21/4/2012 15:22, S. Koukoulas (lists) wrote:

  
    
#
On Sat, Apr 21, 2012 at 3:21 PM, Tim Appelhans <tim.appelhans at gmail.com> wrote:
Except the function doesn't apply to rasters, by which I mean objects
from the raster package.

If you have:

dem = raster("dem.tif")
pts = readShapeSpatial("pts.shp")

then extract(dem,pts) will return the values of the dem raster at the
locations of  the points in pts.

No need to use GRASS or QGIS for this.

Barry