Dear all,

I am currently working with the spatstat package, using windows and pixel 
images.

First:

My aim is to transform a shapefile (see attached) into a pixel image. 

My idea is to start transforming the shapefile into a Spatial Polygon file:

x <- readShapeSpatial("200001441.shp")
y <- as(x, "SpatialPolygons")
z <- as.owin(y)

Given z, I want to identify each polygon with a single constant value. This is 
like adding marks to the SpatialPolygons file. Then I want to convert these 
polygons into an image, such that the value of each pixel corresponds to the 
value associated to the polygon where the pixel lies. 

I have been able to do this individually, polygon by polygon, but then I cannot 
merge the resulting images into a single one. Any idea?

Second:

I would also need a single window containing all the smallest polygons (the 
boundary). I have tried:

w <- union.owin(z)

But the resulting window w still shows internal polygons. As read in spatstas 
FAQ page:

"First, convert each of the regions into a separate owin object. Then apply 
union.owin to combine them."

So I try,

regions <- slot(y, "polygons")
regions <- lapply(regions, function(x) { SpatialPolygons(list(x)) })
windows <- lapply(regions, as.owin) 

But windows is a list of 4307 polygons. How can introduce all of them as a 
single argument?

> M <- union.owin(windows)
Warning messages:
1: In union.owin(windows) : Some arguments were not windows
2: In union.owin(windows) : No windows were given


Thank you very much for you help.

LluĂ­s Hurtado.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to