[R-sig-Geo] Colouring maps so that adjacent polygons differ in colour

Karl Ove Hufthammer karl at huftis.org
Wed Apr 6 10:54:12 CEST 2011

Barry Rowlingson wrote:

>> I've asked Barry off-list about this, there was a case a little while ago
>> with unexpected results because of inserted sliver polygons causing
>> apparently separate observations to be neighbours (the slivers were only
>> visible when zooming right in). There are also differences in the way
>> software may handle precision (snapping). More will follow ...
> Yes, I suspect its precision. poly2nb was showing two km-sized
> regions as disconnected which were 0.01mm (yes, milimetres, about a
> hair's breadth) apart. The rgeos functions had them as connected.

The ‘poly2nb’ function have a ‘snap’ parameter, set to 
‘sqrt(.Machine$double.eps)’ by default. Increasing this
should make the two regions treated as connected.

I guess it’s more surprising that ‘rgeos’ was treating
the two regions as connected by default.

BTW, when talking about the ‘rgeos functions’, do you mean
applying for example ‘gTouches’ to the two regions, or are there
actually a ‘poly2nb’-like function available?

Karl Ove Hufthammer

More information about the R-sig-Geo mailing list