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
Filling polygons with points
5 messages · Wolf, Michael, Duncan Murdoch, Andy Bunn +2 more
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
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.
A good place to start might be with the pip function in splancs. That should do it with a little fussing, I think. require(splancs) data(bodmin) pts <- gen(bodmin$poly,5000) pts.inside <- pip(pts, bodmin$poly) plot(bodmin$poly, asp=1, type="n") pointmap(pts.inside, add=TRUE) polymap(bodmin$poly, add=TRUE) -Andy
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.html
Petr Pikal petr.pikal at precheza.cz
On Thu, 14 Oct 2004, Petr Pikal wrote:
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
Going a bit further, you could use areapl() and gridpts() in splancs to return plotting points for the symbols that would give an even symbol per unit area coverage. This is a very similar question to: https://stat.ethz.ch/pipermail/r-help/2004-September/056351.html which was about dot density maps. A function to do that will be in the next maptools, but I think this is a bit different and is more like a hatching but with arbitrary symbols and chosen spacing - it can be done, but do you need this kind of symbology? Roger
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.html
Petr Pikal petr.pikal at precheza.cz
______________________________________________ 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.html
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: Roger.Bivand at nhh.no