[R-sig-Geo] Re: Holes

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Mon Jan 12 12:02:27 CET 2004


> I'm a bit worried about holes too in the polygon setting, the original
> compiled code in maptools for finding ring direction seems buggy, and ring
> direction seems to be a typical way of flagging holes as against
> boundaries for fill.

  Typical it may be, but I think its the wrong way of doing things! This 
sort of complex geometry would be better represented as a tree of rings. 
  Each ring may have child rings that represent islands or holes within 
the parent (depending on whether the parent is a hole or an island). In 
this way both the island/hole nature is preserved as well as the way 
each is embedded in the other.

  I think you can reconstruct this tree from the rings+holeflag form, 
but it involves doing point-in-poly tests using generated points 
guaranteed to be in a given ring.

  The tree structure leads to nice simple calculation of various 
properties of the rings. Consider a lake with islands with perhaps lakes 
- the area of water of the outer lake is the area(lake ring) minus 
area(child rings), whereas the amount of water within the outer lake is 
area(lake ring) minus amount of water within(child rings), a neat 
tree-based algorithm.

  Given that the tree can be reconstructed from the ring+holeflag 
representation, I'd settle for that if a method for constructing the 
tree is made available.

  Of course in an object-oriented sense, the users shouldn't see the 
representation - there shouldn't be a method for 'area' that returns a 
negative number if the thing is a hole - there should be an 
'isHole(x,y)' method or similar...

  Anyone notice a typo in a recent R-news posting that referred to 
'objection orientation' :)

Baz




More information about the R-sig-Geo mailing list