I have a Mapbox tileset that I have set to an Albers projection, however I have been unsuccessful at getting it to show in the correct conical projection (ie top of continental U.S. is curved) using R Leaflet.
I have tried starting with a barebones leaflet map object and adding the tiles, and also tried setting the leaflet options crs to esri 102003, but I still get a map that is not in the Albers projection. (I've tried tons of other things too, but will leave out for brevity).
How can I maintain the Albers projection for the Mapbox tiles in my leaflet map?
Code with no crs set:
library(tidyverse)
library(leaflet)
library(mapboxapi)
leaflet() %>%
mapboxapi::addMapboxTiles(style_id = "cl9rbsx37000114o3okjal1ej",
username = my_mapbox_user, # You will need a mapbox account and access token to run this, but the style is public
access_token = my_mapbox_token
) %>%
setView(lat = 39.383333, lng = -101.683333, zoom = 5)
Code with crs ESRI 102003:
esri102003 <- leafletCRS(
code = "ESRI:102003",
proj4def = "+proj=aea +lat_0=37.5 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +type=crs"
)
leaflet(options = leafletOptions(crs = esri102003)) %>%
mapboxapi::addMapboxTiles(style_id = "cl5gziyik000114mvx4palaee",
username = "jzadra",
access_token = "pk.eyJ1IjoianphZHJhIiwiYSI6ImNrMWwwb29jYzAwaTMzZHBvNzQ2NDE2NGIifQ.26_gaV_TD6T8I0Hz8oM94g"
) %>%
setView(lat = 39.383333, lng = -101.683333, zoom = 5)
Both of the above code chunks produce this map:
Screenshot of mapbox studio showing albers projection: