starsTileServer {starsTileServer}R Documentation

A R6 class that extends plumber to function as a tile server

Description

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.

Super classes

plumber::Hookable -> plumber::Plumber -> starsTileServer

Methods

Public methods

Inherited methods

Method new()

This method is used to initialize a new tile server

Usage
starsTileServer$new(grid, colorFun = NULL, tileSize = 256, ...)
Arguments
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.

Details

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.

Returns

An starsTileServer object.


Method add_tile_endpoint()

Add three endpoints to the tile server, to return both the tiles and the color scale used.

Usage
starsTileServer$add_tile_endpoint(prefix, handlerFun, colorFun, params)
Arguments
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


Method get_grid()

return the grid used to initialize the function

Usage
starsTileServer$get_grid()

Method get_attributes()

return the attributes of the stars grid

Usage
starsTileServer$get_attributes()

Method get_dimensions()

return the names of the dimensions of the grid

Usage
starsTileServer$get_dimensions()

Method get_dimension_values_chr()

return the values of a dimension as a character

Usage
starsTileServer$get_dimension_values_chr(x)
Arguments
x

the name of the dimension


Method get_non_spatial_dimensions()

return all non spatial dimensions

Usage
starsTileServer$get_non_spatial_dimensions()

Method clone()

The objects of this class are cloneable with this method.

Usage
starsTileServer$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

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)

[Package starsTileServer version 0.1.1 Index]