edzer / sp

Classes and methods for spatial data
http://edzer.github.io/sp/
128 stars 27 forks source link

SpatialLines error with empty list #133

Closed warnes closed 10 months ago

warnes commented 1 year ago

When SpatialLines is called with an empty list, it generates the error:

sp::SpatialLines(list())
Error in bb[1, ] : incorrect number of dimensions
edzer commented 1 year ago

Thanks; yes - sp never handled geometries without points gracefully, it's successor, sf, should do better:

> library(sf)
Linking to GEOS 3.11.1, GDAL 3.6.2, PROJ 9.1.1; sf_use_s2() is TRUE
> st_linestring()
LINESTRING EMPTY
> st_linestring(matrix(1.0,nrow=0,ncol=2))
LINESTRING EMPTY