Dear list, are there any possibilities to fill a polygon with a point pattern or with a symbol pattern like '+' oder '-' instead of shading lines? Thanks in advance Dr. Michael Wolf Bezirksregierung M??nster Dezernat 61 Domplatz 1-3 48161 M??nster Tel.: ++ 49 (02 51) / 4 11 - 17 95 Fax.: ++ 49 (02 51) / 4 11 - 8 17 95 E-Mail: michael.wolf at bezreg-muenster.nrw.de
On Thu, 14 Oct 2004 15:16:30 +0200, "Wolf, Michael" <Michael.Wolf at bezreg-muenster.nrw.de> wrote :>Dear list, > >are there any possibilities to fill a polygon with a point pattern or with a symbol pattern like '+' oder '-' instead of shading lines?I don't think the graphics devices know how to do that, but you could program it yourself: Supposed interior(x,y) is a function that determines whether the points (x,y) are in the polygon, then just create a grid of locations, subset when interior(x,y) is true, and plot using pch='+'. I made a quick search and was unable to find a general implementation of the "interior" function for an arbitrary polygon; I'm a bit surprised about that. Hopefully someone else can point to one, otherwise please write one, and document it and contribute it to R. It's a relatively standard algorithm, and would be useful. Duncan Murdoch
On 14 Oct 2004 at 10:00, Duncan Murdoch wrote:> On Thu, 14 Oct 2004 15:16:30 +0200, "Wolf, Michael" > <Michael.Wolf at bezreg-muenster.nrw.de> wrote : > > >Dear list, > > > >are there any possibilities to fill a polygon with a point pattern or > >with a symbol pattern like '+' oder '-' instead of shading lines? > > I don't think the graphics devices know how to do that, but you could > program it yourself: > > Supposed interior(x,y) is a function that determines whether the > points (x,y) are in the polygon, then just create a grid of locations, > subset when interior(x,y) is true, and plot using pch='+'. > > I made a quick search and was unable to find a general implementation > of the "interior" function for an arbitrary polygon; I'm a bit > surprised about that. Hopefully someone else can point to one,Hi I think that you can find such functionity in splancs package probably function pip() find if points are inside or outside of the polygon. Cheers Petr> otherwise please write one, and document it and contribute it to R. > It's a relatively standard algorithm, and would be useful. > > Duncan Murdoch > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz
<Michael.Wolf at bezreg-muenster.nrw.de> wrote : >Are there any possibilities to fill a polygon with a point pattern or >with a symbol pattern like '+' oder '-' instead of shading lines? In `spatstat' there is code for testing whether points belong to a spatial region. The region can consist of any number of polygons, and the polygons may have holes, etc. While splancs has similar functionality, spatstat additionally allows regions defined by a binary image (e.g. a digital approximation to a circle). The code is available both as a function inside.owin(x,y,win) and as a method for "[" for point pattern objects. Example of "[": library(spatstat) data(demopat) w <- demopat$window # an irregular polygonal window plot(w) g <- as.mask(w, dimyx=c(20,20)) # make a 20 x 20 grid # enclosing the window g <- as.mask(w, eps = 200) # or set absolute grid spacing 200 p <- ppp(raster.x(g), raster.y(g), window=w) # convert to point pattern object p <- p[, w] # clip points to window plot(p) plot(p, pch="+") # etc To create a window object use owin() or as.owin(). Adrian Baddeley