1

I have a spatial polygons data frame whose coordinates I've transformed into gall-stereographic type. But I can't map that spdf with leaflet() now. I'm not sure whether it's a problem with the resolutions I'm providing (because I have no clue what those are or do), or whether it's something to do with the tiled maps I provide via addTiles(), or whether it's something else altogether.

So, before transforming the data to a gall-stereographic projection, everything was fine, I could plot it easily. The output was gorgeous. After... not so much.

I don't have the data on hand to show you what I'm doing, exactly, but the following lines of code should be reproducible with any spdf. I'm pretty sure I'm doing something very obviously wrong -- obvious to anyone familiar with leaflet() -- but the online resources on projections is limited and my familiarity with map projections and the package - even more so. Anyway, here's what I'm doing:

spdf2 <- spTransform(spdf, CRS = CRS("+proj=gall"))

sp::proj4string(spdf2)

leaflet(spdf2, options =
               leafletOptions(
                 crs=leafletCRS(crsClass="L.Proj.CRS",
                                code="ESRI:54016",
                                proj4def= "+proj=gall +ellps=WGS84",
                                resolutions = c(65536, 32768, 16384, 8192, 4096, 2048)
                                ))) %>%  addTiles()

Also tried

addGraticule(sphere = TRUE, style= list(color= '#777', weight= 1, opacity= 0.25))

instead of addTiles, but I'm not sure what it does and it didn't help. Obviously, I'd want to addPolygons after, but for now I just want the map; I can figure out the polygons myself.

EXPECTED:

A pretty map in gall-stereographic format

RESULT:

An empty white nothing.

I expect this is due to the addTiles function, which isn't supposed to give you a map with gall projections. If so, could anyone direct me to a solution, like where to find a map that uses gall projections?

Thanks, guys, I really appreciate it, I've been trying to get it to work for hours and seem to have done everything short of sacrificing my dog to Satan. I'm sorry if I'm wasting your time a bit, I'm just new to leaflet() and crs in general. It's a really cool package though.

0 Answers0