Open bbest opened 6 years ago
Alternative for tiling raster data in Shiny...
jeffreyhanson/tiler: Tiles for visualizing large spatial data
This package requires Python 2.7 to be installed on the system. Additionally, the gdal python library also needs to be installed. This can be achieved by running the following code in the terminal on Ubuntu 16.04.
sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable sudo apt-get update sudo apt-get install gdal-bin python-gdal
Shiny alternative from tiler article:
# load packages
library(shiny)
library(leaflet)
library(tiler)
# define function to build tiles on start
start <- function() {
data(netherlands, package = "mapmisc")
path <<- tiles(nldElev, output_dir = tempdir(), zoom = "10-16", shiny = TRUE)
}
# define ui
ui <- fluidPage(leafletOutput("map"))
# define server function
server <- function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>%
setView(lng = 5.75560, lat = 50.94723, zoom = 12) %>%
addProviderTiles("Esri.WorldImagery", group = "Basemap") %>%
addTiles(path, group = "Elevation",
options = tileOptions(minZoom = 5, maxZoom = 16, tms = TRUE)) %>%
addLayersControl(baseGroups = "Basemap", overlayGroups = "Elevation",
options = layersControlOptions(collapsed = FALSE))
})
}
# launch shiny app
shinyApp(ui, server, onStart = start)
An alternative in Python...
Datashader — datashader 0.6.2 documentation
Datashader is a graphics pipeline system for creating meaningful representations of large datasets quickly and flexibly. Datashader breaks the creation of images into a series of explicit steps that allow computations to be done on intermediate representations. This approach allows accurate and effective visualizations to be produced automatically, and also makes it simple for data scientists to focus on particular data and relationships of interest in a principled way. Using highly optimized rendering routines written in Python but compiled to machine code using Numba, datashader makes it practical to work with extremely large datasets even on standard hardware.
import datashader as ds
import datashader.transfer_functions as tf
import pandas as pd
df = pd.read_csv('user_data.csv')
cvs = ds.Canvas(plot_width=400, plot_height=400)
agg = cvs.points(df, 'x_col', 'y_col', ds.mean('z_col'))
img = tf.shade(agg, cmap=['lightblue', 'darkblue'], how='log')
Here's some of the GeoServer documentation I'd use to optimize serving up the imagery as a WMS service using the Image Mosaic service: