Dear List,

Thanks Adrian for your suggestion. I tried it but unfortunately my
shapefiles are "messy" so the pixellate.owin regularly fails.

I have a solution now based on the earlier posts from Paul and Robert. I
briefly outlined it below, maybe it will be useful to someone in the future:

# bounding box of the end raster

w=3600000
s=2200000
e=4800000
n=2800000

# load libraries
library(maptools)
library(raster)
library(sp)
library(rgdal)

rastToPoly <- function(e,w,n,s,shapename, outdir){
# read shapefile, assuming in the right directory already
shape <- readShapePoly(shapename)
# i subdivided the area to into 100km² tiles
    for (i in seq(w,e,by=100000)){
        for (j in seq(s,n,by=100000)){
            xx <- seq(i,i+100000,by=100)
            yy <- seq(j,j+100000,by=100)
            g <- expand.grid(xx,yy)
            coordinates(g) <- c("Var1","Var2")
            gridded(g) <- T
            r <- raster(g)
            try(pr <- polygonsToRaster(shape, r, -1, progress="text"))
            ra <- aggregate(pr, 10, sum, progress="text")
            writeRaster(ra, paste(outdir,"/raster",i,"_",j,".asc",sep=""),
format="ascii")
        }
    }
}

Then I patched the tiles together with GRASS. Thanks everyone for your help.

Regards Johannes

On Thu, Dec 24, 2009 at 2:43 AM, <Adrian.Baddeley@csiro.au> wrote:

> Johannes Signer <j.m.signer@gmail.com> writes:
>
> > I have a shapefile, that I want to overlay with a raster
> > and then assign each raster cell a value that represents
> > the percentage covered by the shape file.
>
> In the 'spatstat' package the function 'pixellate.owin' does this
> calculation.
>
> ----
> Prof Adrian Baddeley (UWA/CSIRO)
> CSIRO Mathematical and Information Sciences
> Leeuwin Centre, 65 Brockway Road, Floreat WA 6014, Australia
> Tel: 08 9333 6177 | Fax: 08 9333 6121 | Mob: 0410 447 821
>

	[[alternative HTML version deleted]]

