Leaflet: Simple features with ZM dimensions fail to map

Created on 2 Dec 2017  路  2Comments  路  Source: rstudio/leaflet

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()

Most helpful comment

Yip, it doesn't hurt. We do this in mapview in addFeatures

All 2 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mstrimas picture mstrimas  路  3Comments

BastienFR picture BastienFR  路  5Comments

gdmcdonald picture gdmcdonald  路  4Comments

BilboBaagins picture BilboBaagins  路  3Comments

hadley picture hadley  路  5Comments