[R-sig-Geo] overlay SpatialPolygons and SpatialGridDataFrame, overlay

Patrick Giraudoux patrick.giraudoux at univ-fcomte.fr
Wed Dec 23 15:58:43 CET 2009


I am trying to clip a SpatialGridDataframe using a SpatialPolygonsObject 
(actually a simple rectangle, e.g. a region), the ultimate aim being to 
extract the corresponding area to a new SpatialGridDataFrame 
corresponding to the region. I was supposing that I can start doing it 
using the overlay function. Here we are:

region<-matrix(c(73.5,18.1,73.5,54,135,54,135,18.1,73.5,18.1),ncol=2,byrow=T)
region<-SpatialPolygons(list(Polygons(list(Polygon(region)),ID=1)))

idx<-overlay(WorldTemp,region)

WorldTemp[!is.na(idx),]

I get:

Error in WorldTemp[!is.na(idx), ] :
  (subscript) logical subscript too long

The SpatialGridDataframe has  259200 pixels. Am I too greedy and is 
there really a limitation in length?

A second step would be to compute the upper left coordinates, etc... to 
get the new SpatialGridDataFrame But this is another story...



More information about the R-sig-Geo mailing list