Robert,

That is a bug which will be fixed in version 1.9-21. Thanks for reporting.

A possible work around:

m <- mask( raster_stack[[1]], SpatialPolygonDataFrame)
raster_mask <- mask(raster_stack, m)

or

m <- rasterize(raster_stack,  SpatialPolygonDataFrame)
raster_mask <- mask(raster_stack, m)


Best, Robert

On Tue, Sep 27, 2011 at 6:32 AM, Robert Buitenwerf <
buitenwerf@em.uni-frankfurt.de> wrote:

> Dear members,
>
> I am very happily using the raster package but here is a problem I can't
> solve.
>
> When I use the mask function on  a RasterBrick or RasterStack:
>
> raster_mask <- mask( raster_stack, SpatialPolygonDataFrame)
>
> raster returns a RasterLayer and gives me a warning:
>
> "In .rasterFromRasterFile(grdfile, band = band, objecttype) : size of
> values file does not match the number of cells (given the data type)"
>
> When I use mask on a single layer from a brick or stack (e.g. mask(
> RasterStack[1], SpatialPolygon*) ) it returns a correctly masked
> rasterlayer.
>
> I am trying to mask with a SpatialPolygonDataFrame, read in with
> readShapePoly of the maptools package.
> R version 2.13.0 (2011-04-13)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
>
> I am sure I missed something simple and I hope someone would point it out
> to me.
>
> Thanks,
> Robert
>
> ______________________________**_________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>

	[[alternative HTML version deleted]]

