unable to create a leaflet map and add any point in projection ESPG27572

Hello! I'm trying to use Lambert II projection with leaflet. Thus I'm using leafletCRS to create a custom projection. However I got nothing when I want to show a point. This is my code :

minZoom = 0
maxZoom = 13
resolutions <- 0.42*(2^(maxZoom:minZoom))
proj4def_espg27572 <- "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs"
crs_espg27572 <- leafletCRS(crsClass = "L.CRS.Simple", code = "EPSG:27572",proj4def = proj4def_espg27572,resolutions = resolutions,origin = c(0, 0))
map <- leaflet(options = leafletOptions(worldCopyJump = F,crs = crs_espg27572))  %>% addTiles() %>% addMarkers(lng =600234.746122 ,lat = 2429394.875860,label ="75001-Paris 1")

Thanks for your help!

Your code uses addTiles() - which will not work for any other CRS than WGS84 (angular units - lat / lon pairs).

Your code will display your point as expected, but as the basemap tiles are available only in Web Mercator it will be a dull map.

hello @jlacko. thks!
so to project with the basemap tiles, i'm transform my point with str_tranform into WGS84 point :wink:

That is what I would do.

In most cases it is easier to sf::st_transform() your vector data to WGS84 for interactive mapping - and take advantage of the standardized basemaps - than to keep your data in a local CRS and try adjusting the basemaps.

The main use case where this approach does not make sense are the polar regions.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.