Hisaji ONO
2004-May-11 03:54 UTC
[R] How to draw holes generated by gpclib using plot function
Hi. I've tried to create a polygon with one hole by gpclib using following example script. holepoly <- read.polyfile(system.file("poly-ex/hole-poly.txt", package ="gpclib"), nohole = FALSE) area.poly(holepoly) plot(holepoly,poly.args=list(col="red",border="blue")) And I noticed plot function couldn't draw polygons with holes correctly. Does anyone know how to solve this situation? Regards.
Ross Ihaka
2004-May-11 07:40 UTC
[R] How to draw holes generated by gpclib using plot function
Hisaji ONO wrote:> Hi. > > I've tried to create a polygon with one hole by gpclib using following > example script. > > holepoly <- read.polyfile(system.file("poly-ex/hole-poly.txt", package > ="gpclib"), nohole = FALSE) > area.poly(holepoly) > plot(holepoly,poly.args=list(col="red",border="blue")) > > And I noticed plot function couldn't draw polygons with holes correctly. > > Does anyone know how to solve this situation?This is basic constraint in the R graphics system. Polygons must consist of a single (possibly self-intersecting) ring. It would be possible to implement a primitive which is bounded by several non-intersecting rings by joining the interior holes to the outer boundary to create a simply connected shape. Then you could draw the interior with the existing polygon primitive. You can find a more precise description of the process in the FIST (fast industrial-strength triangulation) paper: M. Held (2001): ``FIST: Fast Industrial-Strength Triangulation of Polygons''. Algorithmica 30(4): 563-596, 2001. It would be VERY useful to have an implementation of this (hint, hint!) Alternatively, I think that gpc has an option to return a triangulated version of the polygon. If you get hold of this you could just draw the triangles. though this might be slow for complex polygons. -- Ross Ihaka Email: ihaka at stat.auckland.ac.nz Department of Statistics Phone: (64-9) 373-7599 x 85054 University of Auckland Fax: (64-9) 373-7018 Private Bag 92019, Auckland New Zealand
Roger D. Peng
2004-May-11 12:50 UTC
[R] How to draw holes generated by gpclib using plot function
Sorry, but this limitation in plotting is something that I probably should have mentioned in the help page. At the time when I wrote this plotting wasn't really a priority so I never thought much of it. The GPC C library has a function has a function to return a collection of tristrips but this is not implemented in the R package. It shouldn't be too difficult to include and I will hopefully include it with the next release. -roger Hisaji ONO wrote:> Hi. > > I've tried to create a polygon with one hole by gpclib using following > example script. > > holepoly <- read.polyfile(system.file("poly-ex/hole-poly.txt", package > ="gpclib"), nohole = FALSE) > area.poly(holepoly) > plot(holepoly,poly.args=list(col="red",border="blue")) > > And I noticed plot function couldn't draw polygons with holes correctly. > > Does anyone know how to solve this situation? > > Regards. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >