[R-sig-Geo] invalid geometries from negative buffering in rgeos/sp
Roger Bivand
Roger.Bivand at nhh.no
Mon Oct 7 14:51:44 CEST 2013
On Mon, 7 Oct 2013, Robert J. Hijmans wrote:
> A more general fix might be to support NULL geometries in Spatial objects.
Maybe, but we do not have in sp a class for mixed types of geometries
either, so we would have to define NULL of everything. OGC SFS has NULL,
but I would argue that NULL geometries have no analytical meaning, like a
point with no coordinate values - so we don't know where it is. It doesn't
fit the Spatial class, unless we open for a bounding box with NA corners.
In rgeos, the typical output if there is no positional data is the R NULL
value. One might go towards objects with mixed geometries (GDAL is
permitting them for the drivers that have them in the development
version), but I don't see an analytical need. How often does, for example,
newdata for predicting from a geostatistical model include both points and
lines?
Roger
> Robert
>
> On Thu, Oct 3, 2013 at 6:29 AM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
>> On Thu, 3 Oct 2013, Barry Rowlingson wrote:
>>
>>> Using scot_BNG from the rgdal package:
>>>
>>> dsn <- system.file("vectors", package = "rgdal")[1]
>>> scot_BNG <- readOGR(dsn=dsn, layer="scot_BNG")
>>>
>>> and buffering with a sufficiently large negative width:
>>>
>>> b=gBuffer(scot_BNG,width=-10000,byid=TRUE)
>>>
>>> produces an object that gives an error on plot:
>>
>>
>> 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 ...
>>
>> Roger
>>
>>
>>>
>>>> plot(b)
>>> Error in checkSlotAssignment(object, name, value) :
>>> assignment of an object of class “NULL” is not valid for slot
>>> "coords" in an object of class “Line”; is(value, "matrix") is not TRUE
>>>
>>> Which I think is because the negative buffer has shrunk a feature to
>>> nothing.
>>>
>>> b[1,] is fine but:
>>>
>>>> b[2,]
>>>
>>> Error in SpatialPolygons(x at polygons[i], proj4string = CRS(proj4string(x)))
>>> :
>>> INTEGER() can only be applied to a 'integer', not a 'NULL'
>>>
>>> I'm not sure what the right thing to do here is. Either return a valid
>>> zero-area polygon (if that's not a contradiction in terms) or drop the
>>> degenerate cases?
>>>
>>> Barry
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>> --
>> 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
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
--
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