[R-sig-Geo] raster extract function not working in latest package?

Ariel Ortiz-Bobea aortizbobea at arec.umd.edu
Tue Apr 24 05:13:09 CEST 2012


Hello,

In the past I've managed to extract weights using the raster package on
SpatialPolygons. Now when try to extract the weights I get an empty list on
my platform... 

I'm simply trying to reproduce this example by Robert J. Hijmans:

    /  library(raster)

      r <- raster(ncol=36, nrow=18) 
      r[] <- 1:ncell(r) 
      cds1 <- rbind(c(-180,-20), c(-160,5), c(-60, 0), c(-160,-60),
c(-180,-20)) 
      cds2 <- rbind(c(80,0), c(100,60), c(120,0), c(120,-55), c(80,0)) 
      polys <- SpatialPolygons(list(Polygons(list(Polygon(cds1)), 1), 
                                    Polygons(list(Polygon(cds2)), 2))) 
      
      # visualize
      plot(r)
      plot(polys, add=T)
      
      # extract the cellnumbers and weights 
      v <- extract(r, polys, weights=TRUE, cellnumbers=TRUE) 
      v/

This is what I get for v:

/[[1]]
NULL

[[2]]
NULL/

I'm using the latest raster version (1.9-82 (5-April-2012)) and R 2.15.0 I
downgraded to 2.14.2 on a MacOS and still doesn't work (on two different
computers). I went to another machine running on Windows and raster package
v. 1.8-12 (11-April-2011) on R 2.11.1 and it DID work.

So I guess it's about the version of the package? I don't understand what is
going on. Any suggestion would be appreciated!

Thanks.

Ariel


-----
Ariel Ortiz-Bobea
PhD Candidate in Agricultural & Resource Economics
University of Maryland - College Park
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/raster-extract-function-not-working-in-latest-package-tp7493919p7493919.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list