[R-sig-Geo] invalid geometries from negative buffering in rgeos/sp

Roger Bivand Roger.Bivand at nhh.no
Sun Oct 6 21:53:17 CEST 2013


On Thu, 3 Oct 2013, Barry Rowlingson wrote:

> On Thu, Oct 3, 2013 at 2:29 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
>
>> Yes, but ...
>>
>> The user gets a SpatialPolygonsDataFrame object with the data slot intact,
>> but some of the polygons are clearly now invalid. Should we do
>> book-keeping to only retain the data slot rows for valid polygons, only
>> return the subset of valid polygons, or proceed as now, and have the user
>> do:
>>
>> plot(b[gArea(b, byid=TRUE) > 0,])
>>
>> What makes more sense? I'm open to suggestions ...
>

rgeos 0.3-2 is now on CRAN, and the CRAN Windows and OSX binary packages 
should be built soon. The changes made in rgeos should now prevent invalid 
geometries without valid representation in sp classes, such as empty 
polygons with no coordinates, being built. In gBuffer(), any output GEOM 
empty objects are removed before their conversion back to sp form, 
retaining the ids of the non-empty objects.

Please report back if these changes cause untoward effects in production 
code.

Roger

> I'm first wondering what the source of the invalidity is here. What
> does the underlying GEOS code return from one of these operations?
> Does it have a valid NULL polygon feature concept? If so, then I'd
> like to see that carried through into sp-class objects.
>
> Its not a sufficient condition that the area = 0 - a polygon of three
> coincident points has area=0, but a big negative buffer should be a
> geometry without even points in it...
>
> Barry
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list