Expanding on https://github.com/ropensci/osmplotr/issues/46, here is a suggestion to change a cryptic error to a useful warning.
Essence of the previous issue: if sf is not loaded, the subsetting method [.sf is not available and [.data.frame is used. This causes a cryptic error in
add_osm_objects -> get_obj_type -> tolower -> strsplit
Here's a MWE. Make sure sf is not loaded when runnning it:
I suggest adding a warning / error in get_obj_type in line 19
obj <- dat_F[1:10,]
if(!inherits(obj$geometry, "sfc")) warning("object class is sf, but the geometry",
" column class is '", toString(class(obj$geometry)), "' instead of 'sfc'.\n",
"This can occur e.g. after subsetting sf objects without the sf package loaded.")
Expanding on https://github.com/ropensci/osmplotr/issues/46, here is a suggestion to change a cryptic error to a useful warning. Essence of the previous issue: if
sf
is not loaded, the subsetting method[.sf
is not available and[.data.frame
is used. This causes a cryptic error inadd_osm_objects -> get_obj_type -> tolower -> strsplit
Here's a MWE. Make sure sf is not loaded when runnning it:
I suggest adding a warning / error in
get_obj_type
in line 19