starsTileServer {starsTileServer} | R Documentation |
Creates a tile server based on the R6 class plumber::Plumber
.
In can be created both with a stars
grid as well as a function or list of functions.
The main methods are run
and new
.
plumber::Hookable
-> plumber::Plumber
-> starsTileServer
plumber::Hookable$registerHooks()
plumber::Plumber$addAssets()
plumber::Plumber$addEndpoint()
plumber::Plumber$addFilter()
plumber::Plumber$addGlobalProcessor()
plumber::Plumber$call()
plumber::Plumber$filter()
plumber::Plumber$getApiSpec()
plumber::Plumber$getDebug()
plumber::Plumber$handle()
plumber::Plumber$mount()
plumber::Plumber$onHeaders()
plumber::Plumber$onWSOpen()
plumber::Plumber$openAPIFile()
plumber::Plumber$print()
plumber::Plumber$registerHook()
plumber::Plumber$removeHandle()
plumber::Plumber$route()
plumber::Plumber$run()
plumber::Plumber$serve()
plumber::Plumber$set404Handler()
plumber::Plumber$setApiSpec()
plumber::Plumber$setDebug()
plumber::Plumber$setDocs()
plumber::Plumber$setDocsCallback()
plumber::Plumber$setErrorHandler()
plumber::Plumber$setParsers()
plumber::Plumber$setSerializer()
plumber::Plumber$swaggerFile()
plumber::Plumber$unmount()
new()
This method is used to initialize a new tile server
starsTileServer$new(grid, colorFun = NULL, tileSize = 256, ...)
grid
Either a stars grid, a path pointing towards a gridded file, a function or a list of named functions
colorFun
a color function to use for coloring the map tiles, the function needs to be the same format as leaflet::colorNumeric()
. It is important to specify a color function as it is important to keep the range of the color scale similar between tiles, therefore the minimum and maximum needs to be fixed. It can also be a list of color functions.
tileSize
The size of the tile (generally 256 pixels, and not tested with other sizes)
...
Arguments passed on to the plumber::Plumber, most important is the port
number.
If grid
is a function it should take a stars grid as the first argument and return the grid with the same topology with values attached.
Any other arguments to the function will be part of the API and will be passed to the function as characters.
An starsTileServer
object.
add_tile_endpoint()
Add three endpoints to the tile server, to return both the tiles and the color scale used.
starsTileServer$add_tile_endpoint(prefix, handlerFun, colorFun, params)
prefix
the name to be used by the server for this tile server
handlerFun
The function that handles the api request and returns the grid
colorFun
The color function to use for example leaflet::colorNumeric()
params
parameters passed on to the new
method of plumber::PlumberEndpoint
get_grid()
return the grid used to initialize the function
starsTileServer$get_grid()
get_attributes()
return the attributes of the stars grid
starsTileServer$get_attributes()
get_dimensions()
return the names of the dimensions of the grid
starsTileServer$get_dimensions()
get_dimension_values_chr()
return the values of a dimension as a character
starsTileServer$get_dimension_values_chr(x)
x
the name of the dimension
get_non_spatial_dimensions()
return all non spatial dimensions
starsTileServer$get_non_spatial_dimensions()
clone()
The objects of this class are cloneable with this method.
starsTileServer$clone(deep = FALSE)
deep
Whether to make a deep clone.
m <- matrix(1:20, nrow = 5, ncol = 4)
dim(m) <- c(x = 5, y = 4) # named dim
(s <- stars::st_as_stars(m))
sf::st_crs(s) <- 4326
starsTileServer$new(s)
# Working directly from a file
grid <- system.file("tif/L7_ETMs.tif", package = "stars")
starsTileServer$new(grid)
## Not run:
starsTileServer$new(s)$run()
## End(Not run)