Re: [R] How to draw holes generated by gpclib using plot function

About this list Date view Thread view Subject view Author view Attachment view

From: Roger Bivand (Roger.Bivand@nhh.no)
Date: Wed 12 May 2004 - 05:40:21 EST


Message-id: <Pine.LNX.4.44.0405112105270.5082-100000@reclus.nhh.no>

On Tue, 11 May 2004, Ross Ihaka wrote:

> 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!)
>

Is an unpleasing fix to accept the overfilling, and to order (and mark if
known) the contained polygons - some GIS use ring direction to suggest
which are lakes and which islands? This may mean that some polygons get
painted several times, but I don't know if this is avoidable at present.
For Hisaji's problem this would mean overpainting the later hole with a
background colour (not "transparent" or NA), setting this as the col=
argument in polygon(). For many polygons finding which are inside which,
to set the painting order, could be messy by brute force, but would just
need to output an index vector to re-order the polygons and the painting
col= argument. Before several packages try to solve/find working though
admittedly ugly fixes to this separately, should we share ideas?

> 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.
>
>
>

-- 
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@nhh.no

______________________________________________ R-help@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


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:09 EST