Simple features with ZM dimensions fail to map
Leaflet will not render linestrings with Z or ZM dimensions. Instead it gives an obscure error with an obscure traceback. It would be helpful if leaflet removed or ignored the ZM dimensions or at least gave a helpful error message.
library(leaflet)
library(magrittr)
library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.1.3, proj.4 4.9.3
s1 <- rbind(c(0,3,1),c(0,4,1),c(1,5,1),c(2,5,1))
(ls <- st_linestring(s1))
#> LINESTRING Z (0 3 1, 0 4 1, 1 5 1, 2 5 1)
leaflet(ls) %>% addPolylines()
#> Error in if (length(nms) != n || any(nms == "")) stop("'options' must be a fully named list, or have no names (NULL)"): missing value where TRUE/FALSE needed
# Works
leaflet(st_zm(ls)) %>% addPolylines()
Looks like there's no harm in calling st_zm() on a linestring that already doesn't have ZM, should we just do that always? @bhaskarvk @timelyportfolio
Yip, it doesn't hurt. We do this in mapview in addFeatures
I just ran into this issue today. Any chance you are going to implement the fix of calling st_zm()? It seems to work if I do that in advance
I just ran into this issue too, after hearing from someone trying to use a web app of ours that's been in the wild without problems for more than a year. st_zm() fixed this for me, but I would have saved an hour if it had been done in leaflet.