-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create max augement to set number of features to show on map with sensible default #25
Comments
Reproducible example below. The idea is that the view function (existing or created) will check the number of features (or maybe vertices with |
# reproducible example
library(stplanr)
ac <- read_stats19_ac() # 214 mb compressed data
names(ac)
ac = ac[!is.na(ac$Latitude), ]
ac_sf = sf::st_as_sf(ac, coords = c("Longitude", "Latitude"))
pryr::object_size(ac_sf) # 600 MB
# now we've generated a large spatial dataset let's see how long it takes to visualize
system.time({
plot(ac_sf$geometry) # note: blocks your R session for ages: unhelpful, we need an alternative!
})
system.time({
plot(ac_sf$geometry[sample(nrow(ac_sf), size = 1e4)]) # way faster but also clunky
})
# now interactively
mapview::mapview(ac_sf) # freezes your R session
# with leaflet WIP...
library(leaflet)
# with geoplumber ...
|
Here's the beginnings of making the max arg work:
|
Poor "plumber", cannot convert sf object into GeoJSON on its own. I wonder if @SymbollixAU would like to have a look at (1) or perhaps open an issue so we can continue using # Below is part of stats19 endpoint:
library(stplanr)
ac <- read_stats19_ac() # 214 mb compressed data
names(ac)
ac = ac[!is.na(ac$Latitude), ]
ac_sf = sf::st_as_sf(ac, coords = c("Longitude", "Latitude"), crs = 4326)
b = spData::lnd
ac_lnd = ac_sf[b, ]
plot(sf::st_geometry(ac_lnd[sample(nrow(ac_lnd), 1000), ]))
ac_sf_mini = ac_sf[1:1000, ]
ac_sf_mini <- geojsonio::geojson_json(ac_sf_mini)
#' @get /api/uol
uol_geojson <- function(res){
res$headers$`Content-type` <- "application/json" # not necessary.
res$body <- ac_sf_mini
res
} |
Heads-up @SymbolixAU - @layik the tag didn't work 1st time around. Maybe open-up an issue if one would be appreciated 😄 |
closed in SymbolixAU/geojsonsf#29 (comment) you need to use |
Thanks @SymbolixAU Correct code then: # Below is part of stats19 endpoint:
library(stplanr)
ac <- read_stats19_ac() # 214 mb compressed data
names(ac)
ac = ac[!is.na(ac$Latitude), ]
ac_sf = sf::st_as_sf(ac, coords = c("Longitude", "Latitude"), crs = 4326)
b = spData::lnd
ac_lnd = ac_sf[b, ]
plot(sf::st_geometry(ac_lnd[sample(nrow(ac_lnd), 1000), ]))
ac_sf_mini = ac_sf[1:1000, ]
ac_sf_mini <- geojsonsf::sf_geojson(ac_sf_mini)
#' @get /api/uol
uol_geojson <- function(res){
res$headers$`Content-type` <- "application/json" # not necessary.
res$body <- ac_sf_mini
res
} |
Other tickets just jump the priority queue over this one. |
title not clear so closing but happy to reopen again. |
No description provided.
The text was updated successfully, but these errors were encountered: