[R-sig-Geo] pixellate.owin when "owin" contains separate, overlapping polygons

Robin W Hunnewell rhunne at mac.com
Sat Jun 4 16:38:44 CEST 2011


Thank you!  I see how this works better now.. 

To answer your query on how I created such an object, it's as you guessed -- to get around violating the code when spatstat.options(checkpolygons=TRUE), which would give error message  "Error in owin(poly = opls) :  Polygon data contain overlaps between polygons," 
I temporarily set it to FALSE in order that my garbled polygon data would be accepted, as least for now! 

I'm not planning to assign such a garbled window to my point pattern data; for that I have a normal, single-poly window. 

But I am seeking a way to generate a smooth estimate of a set of spatially varying occurrences -- the population of survey flights that went on within the boundary of that overall single-poly window.  Idea was to address this as a key spatial covariate underlying the distribution of all my points... hope that makes sense.

Thanks so much for the help!
Robin


On 04 Jun, 2011,at 07:40 AM, Adrian.Baddeley at csiro.au wrote:

Robin W Hunnewell rhunne at mac.com wrote:

> I've used pixellate.owin() to convert an object of class "owin" to a pixel image -- the owin in question is 
> unusual in that it contains multiple, overlapping polygons.

This is a question about the 'spatstat' package.

Out of curiosity - How did you create such an object? The code should refuse to create it, unless you switched off the error checking.... Overlapping polygons violate the requirements of the owin class, and this will cause trouble sooner or later. 

> Now I'd like to change (constrict) the frame area of a resulting "im" object by assigning 
> a different and smaller window to it, using pixellate.owin 

pixellate.owin is not designed to do that. 
The argument 'W' to pixellate.owin is mainly intended as a way of controlling pixel resolution. It is meant to define a pixel raster. The raster must be large enough to contain the original window.

To do what you want, first convert your window to an 'im' object using pixellate.owin (without the 'W' argument), and then trim it to a smaller window using "[.im" as follows (where 'Depth' is your original window and 'ConvexW3' is the desired subwindow)

A <- pixellate(Depth)
B <- A[ConvexW3, drop=FALSE]
C <- B[as.rectangle(ConvexW3)]

Line 2 sets all pixels outside the window 'ConvexW3' to NA. It is needed only if 'ConvexW3' is not a rectangle; it's redundant if 'ConvexW3' is a rectangle. 
Line 3 trims the pixel raster to the smallest valid rectangle.

To control the pixel resolution, for example if you want pixels to have size 'eps', replace line 1 by 

A <- pixellate(Depth, eps=eps)

Adrian Baddeley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110604/b3664248/attachment.html>


More information about the R-sig-Geo mailing list