rdeck icon indicating copy to clipboard operation
rdeck copied to clipboard

possible to use different map projections?

Open DanWismer opened this issue 8 months ago • 3 comments

Great package! I just discovered your work today from reading this blog!

Is it possible to use a different Mapbox GL JS map projection such as Albers? And can you render projected layers on top of the projected basemap?

Thanks!

DanWismer avatar Nov 03 '23 17:11 DanWismer

Great package! I just discovered your work today from reading this blog!

Thanks!

Is it possible to use a different Mapbox GL JS map projection such as Albers?

This is disabled currently, since I've not explored how to do this:

And can you render projected layers on top of the projected basemap?

Projected deck.gl layers might be doable (or even simple) with interleaved rendering (planned).

What {rdeck} maps with different projections will currently look like:

sa1s <-
  strayr::read_absmap("sa12016") |>
  dplyr::mutate(
    position = rdeck::xy(cent_long, cent_lat),
    val = runif(dplyr::n() * as.numeric(state_code_2016)) |>
      round(2)
  )

map <- 
  rdeck::rdeck(initial_bounds = wk::wk_bbox(sa1s$position)) |>
  rdeck::add_scatterplot_layer(
    data = sa1s,
    radius_min_pixels = 5,
    get_fill_color = rdeck::scale_color_linear(val)
  )

# HACK: change projection
map$x$mapgl$projection <- "albers"

# render
map

rdeck

anthonynorth avatar Nov 06 '23 05:11 anthonynorth

This is awesome!

If there a way to get the basemap to align with those points?

Can you do this albers projection with a raster?

For some some context, I have only built web maps using leaflet and have been searching for a way to have a projected raster (or tiles) not in web Mercator overlay a projected basemap not in web Mercator.

DanWismer avatar Nov 06 '23 15:11 DanWismer

The deck.gl map controller only supports web mercator, so the example above has very weird behaviour for the basemap and isn't usable with or without data.

If there a way to get the basemap to align with those points? Can you do this albers projection with a raster?

Maybe. Exploration needed to know for sure.

I think first steps are to pivot to MapboxOverlay api which makes the mapbox basemap the controller. That would make the basemap behave correctly, also allows for simple switching between interleave/overlay modes. Deck.gl layers working with different mapbox projections is an unknown.

anthonynorth avatar Nov 07 '23 02:11 anthonynorth