As per the documentation, leaflet in R supports projected coordinate reference systems. I cannot make this work, however.
Given any sf polygon object in projected coordinate system EPSG:27700 (called myprojectedsfobject), running the code block below the screen shot is given with the error commented in the code.
crs <- leafletCRS(
code = "EPSG:27700",
proj4def =
"+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs")
leaflet(options = leafletOptions(crs = crs)) %>%
addPolygons(data = myprojectedsfobject, label = ~htmlEscape(NAME_3), fill = FALSE)
#Warning messages:
#1: sf layer is not long-lat data
#2: sf layer has inconsistent datum (+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 #+y_0=-100000 +ellps=airy +units=m +no_defs).
#Need '+proj=longlat +datum=WGS84'
Can anyone help with how to correctly implement projected coordinate systems in leaflet in R?
