Open edmundseto opened 10 months ago
Thanks for developing this package. It's amazing! Thanks!
What you're trying to do is not (yet) supported in {rdeck}. Scales and accessors work on a single column (or field for tiles). Are you able to modify the tileset to add an additional (redundant) field?
Correct, single-column visualizations are working nicely!
But, for the tool I'm working on, I'd like to allow users to use a R Shiny interface to pick and choose columns to combine into their own composited variable for mapping -- like a dplry::mutate() statement after the accessor grabs the tiles within the viewing bounds and the vector attribute fields. Not sure I could pre-propulate the various combinations of the 50-some attribute columns, as I'd like to give the user's a lot of flexibility on how to do the compositing.
I'm been slowly reading how R interfaces with javascript, and some other R mapping interfaces. If I find something that works, I'll report back here.
Thanks.
Closing the loop for anyone who comes across this thread...
It's not based on rdeck or Deckgl, but I was able to use the R mapboxer package to access vector tiles and create composite variables based on multiple fields in the tiles. That package is basically an R interface to Mapbox GL JS, and thus involves creating list-like Mapbox GL JS style statements. The example below computes an average of two variables, and uses the result for a choropleth map. Since it's just a list, it can be constructed in R before calling add_layer, for example in R Shiny dynamically.
add_layer(style = list(
id = "myblocks", # unique name for the mapboxer layer
type = "fill", # polygons fill and optionally stroked
source = my_tile_source, # defined by previous mapbox_source() call
"source-layer" = "blocks", # the layer name defined in the tile
paint = list( # this is Mapbox GL JS-like style code...
"fill-color" = list(
"interpolate",
list("linear"),
list ("/",
list ("+",
list("get", "A_variable"), # one of the tile fields
list("get", "B_variable"), # another tile field
2),
0, '#edf8b1',
1, '#3e5fd8'
),
"fill-outline-color" = "#7d7d7d",
"fill-opacity" = 0.5
)
)))
Hi,
Thanks for developing this package. It's amazing! I'm new to this, so forgive me for probably a simple question. I've been looking for more examples, and haven't come across what I need.
I'm trying to add two numeric data fields from my vector tile, and use the results in the color scaling function for the map. The code below works with just one data field (DM_W), but not when I try to combine two fields (e.g., DM_W + DM_A) as shown. Any suggestions would be appreciated.
I get an error...
From the ensym() error, I think it's expecting just a column name rather than an expression, but my R skills aren't good enough to come up with a work around.