Skip to content

Support for CRS.Simple #13

@AB-Kent

Description

@AB-Kent

Would it be possible to support maps which are not in the standard projection? Specifically I would like to use addGlPoints with a map created using L.CRS.Simple. My base map is a microscope image of a tissue section; I would like to draw points representing hundreds of thousands of cells as a layer on top. It works (slowly) to use leaflet::addCircles with coordinates in the range 0-255; this fails with leafgl::addGlPoints because it tries to convert the points to EPSG:4326.

Example with no base map:

library(leaflet)
library(leafgl)
library(magrittr)

n=1000
pts = data.frame(id = 1:n,
                 x = rnorm(n, 128, 30),
                 y = rnorm(n, -128, 18))

crs <- leafletCRS(crsClass = "L.CRS.Simple")
map = leaflet(options = leafletOptions(crs = crs)) %>% 
  setView(128, -128, 1) 

# Works
map %>% addCircles(data=pts, lat=~y, lng=~x)

# Doesn't work
map %>% addGlPoints(st_as_sf(pts, coords=c('x', 'y')))

#Error in st_transform.sfc(st_geometry(x), crs, ...) : 
#  sfc object should have crs set
#Calls: %>% ... st_transform.sf -> st_transform -> st_transform.sfc

Metadata

Metadata

Assignees

No one assigned

    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