Great, many thanks Matteo.
On 14/03/2013 22:00, "Matteo Mattiuzzi"
wrote:
>And of coarse the last step was not completely right:
>...
>myPointsDf <- as.data.frame(myPointsSp)
>vals <- extract(myRaster,myPointsSp)
>myPointsDf <- cbind(myPointsDf,vals)
>
>
>
>so now the values are in your data.fr
And of coarse the last step was not completely right:
...
myPointsDf <- as.data.frame(myPointsSp)
vals <- extract(myRaster,myPointsSp)
myPointsDf <- cbind(myPointsDf,vals)
so now the values are in your data.frame, or maybe also this is ok:
myDf <- extract(myRaster,myPointsSp,df=TRUE)
>>>
Dear Ross,
set.seed(1234)
myPointsSp <- data.frame(x=rnorm(10, mean=1.23347499, sd=0.002),
y=rnorm(10, mean=52.00096, sd=0.002))
coordinates(myPointsSp) <- c('x', 'y')
proj4string(myPointsSp) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84")
# make raster
myExtent <- extent(myPointsSp)
myRaster