Skip to content
Prev 22098 / 29559 Next

Extract with Large Rasters

Hello, see response inline.
On Wed Dec 17 2014 at 10:03:23 Michael Treglia <mtreglia at gmail.com> wrote:

            
There's a few problems with your code,  you should never use @ for getting
and setting slots, and besides you can assign to the data with $ in the
usual way (the developers do use @ in internal code to provide high level
methods that behave in defined ways). I would do it like this:

library(raster)

## simulate a raster, not large
r <- raster(volcano, crs = "+proj=laea")

## more fake data
pts0 <- xyFromCell(r, sample(ncell(r), 10), sp = TRUE)
pts <- SpatialPointsDataFrame(pts, data.frame(id =
1:nrow(coordinates(pts0))))

## rather than points at data <- etc.
pts$r <- extract(r, pts)

That might help  if the overall points data is large, but you didn't
include that information. You could use print(points) (with raster loaded)
for a succinct summary. (Also points is a commonly used function so best
avoided as a name).


Cheers, Mike.