SymbolixAU / mapdeck

R interface to Deck.gl and Mapbox
https://symbolixau.github.io/mapdeck/articles/mapdeck.html
363 stars 40 forks source link

spatialwidget extras #76

Closed SymbolixAU closed 5 years ago

SymbolixAU commented 6 years ago

Various updates I've noted while implementing spatialwidget

TODO

NOTES to document

SymbolixAU commented 6 years ago

if geometry.geometry.coordinates === undefined, returning [null, null] actually renders a point at [0, 0]. I don't like this.

SymbolixAU commented 6 years ago

benchmarking defaults

library(sf)
library(geojsonsf)

sf <- geojson_sf("https://symbolixau.github.io/data/geojson/SA2_2016_VIC.json")

sf <- rbind(sf, sf, sf, sf, sf, sf)
sf <- rbind(sf, sf, sf, sf, sf, sf)

nrow( sf )

library(microbenchmark)

microbenchmark(
    defaults = {
        m <- mapdeck() %>%
            add_polygon(
                data = sf
                , fill_colour = "SA2_NAME16"
                , stroke_colour = "SA2_NAME16"
                , elevation = "AREASQKM16"
                , with_defaults = TRUE
            )
    },
    no_defaults = {
        m <- mapdeck() %>%
            add_polygon(
                data = sf
                , fill_colour = "SA2_NAME16"
                , stroke_colour = "SA2_NAME16"
                , elevation = "AREASQKM16"
                , with_defaults = FALSE
            )
    },
    times = 5
)

# Unit: seconds
#        expr      min       lq     mean   median       uq      max neval
#    defaults 13.12390 13.68061 13.66652 13.68431 13.71192 14.13188     5
# no_defaults 13.15613 13.65578 13.64815 13.68355 13.83006 13.91527     5

no real benefit...

mdsumner commented 5 years ago

If you want rando comments, I notice is the update_view focus only works if the sf is in longlat/4326, so there's an assumption about the bounding box - being used directly I supposed, so it always exceeds the world. for a projection (It's not a trivial thing to determine, in general - though small extents will generally be straightforward)

SymbolixAU commented 5 years ago

yeah I probably need to make it explicitly clear in the docs all coords need to be in 4326

mdsumner commented 5 years ago

Ah yes,I slowly realized what was actually wrong at a deeper level 😀