Skip to content

Simple features with ZM dimensions fail to map #482

Description

@kent37

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

Activity

  1. jcheng5 commented on Dec 3, 2017

    @jcheng5
    Member

    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

  2. tim-salabim commented on Dec 3, 2017

    @tim-salabim
    Contributor

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

  3. see24 commented on Apr 8, 2025

    @see24

    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

  4. bwcompton commented on Oct 8, 2025

    @bwcompton

    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.

  5. added a commit that references this issue on Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions