| Title: | Interactive GIS with 'GeoLibre' |
|---|---|
| Description: | Embeds the full 'GeoLibre' geographic information system in 'R Markdown', 'Quarto', 'Shiny', and the 'RStudio' Viewer. Create maps from 'GeoJSON' and 'sf' objects, markers, heatmaps, and tabular coordinates; add 'Cloud Optimized GeoTIFF', 'XYZ', 'WMS', 'WMTS', 'WFS', 'PMTiles', vector tile, '3D Tiles', and video sources; classify choropleths, arrange layers, and add legends, colorbars, and split-map comparisons. Control the camera, export standalone 'HTML', and read and write '.geolibre.json' project files. The underlying application is described in Wu (2026) <doi:10.5281/zenodo.20785400>. |
| Authors: | Qiusheng Wu [aut, cre], Open Geospatial Solutions [cph] |
| Maintainer: | Qiusheng Wu <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-10-05 11:15:41 UTC |
| Source: | https://github.com/opengeos/geolibre-r |
Add a 3D Tiles layer
add_3d_tiles( map, url, name = "3D Tiles", altitude_offset = 0, request_headers = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_3d_tiles( map, url, name = "3D Tiles", altitude_offset = 0, request_headers = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
url |
URL of the 3D Tiles |
name |
Layer name. |
altitude_offset |
Vertical offset applied to the tileset, in meters. |
request_headers |
Optional named list of request headers. These are
stored in the project, so avoid persisting secrets; |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_3d_tiles("https://example.com/tileset.json", altitude_offset = 20) stopifnot(map$x$project$layers[[1]]$type == "3d-tiles")map <- geolibre() |> add_3d_tiles("https://example.com/tileset.json", altitude_offset = 20) stopifnot(map$x$project$layers[[1]]$type == "3d-tiles")
Classifies column into class_count numeric ranges and colors each range
from colormap, producing the same graduated symbology the application's
Style panel builds from the interface.
add_choropleth( map, data, column, name = "Choropleth", class_count = 5, colormap = "viridis", scheme = c("equal-interval", "quantile"), style = list(), visible = TRUE, opacity = 1, ... )add_choropleth( map, data, column, name = "Choropleth", class_count = 5, colormap = "viridis", scheme = c("equal-interval", "quantile"), style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
data |
GeoJSON as a parsed list (a |
column |
Name of the numeric feature property to classify. |
name |
Layer name. |
class_count |
Number of classes, clamped to between 2 and 12. |
colormap |
A color ramp name from |
scheme |
Classification scheme, |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
classify_layer() to symbolize a layer that is already on the map.
counties <- list( type = "FeatureCollection", features = list( list( type = "Feature", properties = list(pop = 100), geometry = list(type = "Point", coordinates = c(-77, 39)) ), list( type = "Feature", properties = list(pop = 900), geometry = list(type = "Point", coordinates = c(-76, 40)) ) ) ) map <- geolibre() |> add_choropleth(counties, column = "pop", colormap = "blues", class_count = 3) stopifnot(map$x$project$layers[[1]]$style$vectorStyleMode == "graduated")counties <- list( type = "FeatureCollection", features = list( list( type = "Feature", properties = list(pop = 100), geometry = list(type = "Point", coordinates = c(-77, 39)) ), list( type = "Feature", properties = list(pop = 900), geometry = list(type = "Point", coordinates = c(-76, 40)) ) ) ) map <- geolibre() |> add_choropleth(counties, column = "pop", colormap = "blues", class_count = 3) stopifnot(map$x$project$layers[[1]]$style$vectorStyleMode == "graduated")
add_markers() with the circle radius surfaced as a named argument.
add_circle_markers( map, points, name = "Circle Markers", radius = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_circle_markers( map, points, name = "Circle Markers", radius = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
points |
Points as a two-column matrix or a data frame of coordinates, a
list of |
name |
Layer name. |
radius |
Optional circle radius in pixels. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_circle_markers(list(c(-77, 39)), radius = 12, fillColor = "#16a34a")map <- geolibre() |> add_circle_markers(list(c(-77, 39)), radius = 12, fillColor = "#16a34a")
Add a Cloud Optimized GeoTIFF layer
add_cog( map, url, name = "COG", bands = NULL, colormap = NULL, rescale = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_cog( map, url, name = "COG", bands = NULL, colormap = NULL, rescale = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
url |
Public HTTP(S) URL of a Cloud Optimized GeoTIFF or GeoTIFF. |
name |
Layer name. |
bands |
Optional one-based band indices. Three or more bands render as
RGB; one renders as a single band, which |
colormap |
Optional GeoLibre colormap name for single-band rendering. |
rescale |
Optional list of numeric |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
add_raster(), add_tile_layer(), add_colorbar()
map <- geolibre() |> add_cog("https://example.com/image.tif", bands = c(1, 2, 3)) stopifnot(map$x$project$layers[[1]]$type == "cog")map <- geolibre() |> add_cog("https://example.com/image.tif", bands = c(1, 2, 3)) stopifnot(map$x$project$layers[[1]]$type == "cog")
Renders a gradient with minimum and maximum ticks, from either a named color ramp or an explicit list of CSS colors. Each call adds another colorbar.
add_colorbar( map, colormap = "viridis", vmin = 0, vmax = 1, label = "", units = "", colors = NULL, orientation = c("vertical", "horizontal"), position = c("bottom-right", "bottom-left", "top-left", "top-right") )add_colorbar( map, colormap = "viridis", vmin = 0, vmax = 1, label = "", units = "", colors = NULL, orientation = c("vertical", "horizontal"), position = c("bottom-right", "bottom-left", "top-left", "top-right") )
map |
A GeoLibre widget. |
colormap |
A color ramp name from |
vmin |
Value at the low end of the colorbar. |
vmax |
Value at the high end of the colorbar. |
label |
Title shown alongside the colorbar. |
units |
Units suffix shown with the values. |
colors |
Optional character vector of CSS colors defining a custom
gradient, used instead of |
orientation |
|
position |
Corner for the colorbar: |
The modified widget.
add_legend() for categorical classes
map <- geolibre() |> add_raster("https://example.com/dem.tif", bands = 1, colormap = "terrain") |> add_colorbar( colormap = "terrain", vmin = 0, vmax = 3000, label = "Elevation", units = "m" )map <- geolibre() |> add_raster("https://example.com/dem.tif", bands = 1, colormap = "terrain") |> add_colorbar( colormap = "terrain", vmin = 0, vmax = 3000, label = "Elevation", units = "m" )
add_colorbar() with colormap in the leading position, for parity with the
Python API.
add_colormap(map, colormap = "viridis", vmin = 0, vmax = 1, label = "", ...)add_colormap(map, colormap = "viridis", vmin = 0, vmax = 1, label = "", ...)
map |
A GeoLibre widget. |
colormap |
A color ramp name from |
vmin |
Value at the low end of the colorbar. |
vmax |
Value at the high end of the colorbar. |
label |
Title shown alongside the colorbar. |
... |
Forwarded to |
The modified widget.
geolibre() |> add_colormap("plasma", vmin = 0, vmax = 100, label = "Index")geolibre() |> add_colormap("plasma", vmin = 0, vmax = 100, label = "Index")
add_xy_data() with a CSV-oriented default layer name.
add_csv( map, data, x = "longitude", y = "latitude", name = "CSV", style = list(), visible = TRUE, opacity = 1, ... )add_csv( map, data, x = "longitude", y = "latitude", name = "CSV", style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
data |
A data frame, a CSV file path, a CSV URL, CSV text, or a list of row lists. |
x |
Name of the longitude column. |
y |
Name of the latitude column. |
name |
Layer name. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
text <- "name,longitude,latitude\nDC,-77.0369,38.9072" map <- geolibre() |> add_csv(text)text <- "name,longitude,latitude\nDC,-77.0369,38.9072" map <- geolibre() |> add_csv(text)
With column supplied this is add_choropleth(); without it, add_geojson().
Provided for parity with the Python API.
add_data(map, data, column = NULL, name = "Data", ...)add_data(map, data, column = NULL, name = "Data", ...)
map |
A GeoLibre widget. |
data |
GeoJSON as a parsed list (a |
column |
Optional numeric property to drive graduated symbology. |
name |
Layer name. |
... |
Forwarded to |
The modified widget.
point <- list(type = "Point", coordinates = c(-77, 39)) map <- geolibre() |> add_data(point, name = "Point")point <- list(type = "Point", coordinates = c(-77, 39)) map <- geolibre() |> add_data(point, name = "Point")
Add a FlatGeobuf layer
add_flatgeobuf(map, data, name = "FlatGeobuf", ...)add_flatgeobuf(map, data, name = "FlatGeobuf", ...)
map |
A GeoLibre widget. |
data |
A dataset URL, a local file path, or an |
name |
Layer name. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
geolibre() |> add_flatgeobuf("https://example.com/data.fgb")geolibre() |> add_flatgeobuf("https://example.com/data.fgb")
Add GeoJSON to a GeoLibre map
add_geojson( map, data, name = "GeoJSON", style = list(), visible = TRUE, opacity = 1, ... )add_geojson( map, data, name = "GeoJSON", style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
data |
GeoJSON as a parsed list (a |
name |
Layer name. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
add_sf(), add_choropleth(), add_vector()
point <- list( type = "Feature", properties = list(name = "Washington, DC"), geometry = list(type = "Point", coordinates = c(-77.0369, 38.9072)) ) map <- geolibre() |> add_geojson(point, name = "Places", fillColor = "#dc2626") stopifnot(length(map$x$project$layers) == 1L)point <- list( type = "Feature", properties = list(name = "Washington, DC"), geometry = list(type = "Point", coordinates = c(-77.0369, 38.9072)) ) map <- geolibre() |> add_geojson(point, name = "Places", fillColor = "#dc2626") stopifnot(length(map$x$project$layers) == 1L)
Add a GeoParquet layer
add_geoparquet(map, data, name = "GeoParquet", ...)add_geoparquet(map, data, name = "GeoParquet", ...)
map |
A GeoLibre widget. |
data |
A dataset URL, a local file path, or an |
name |
Layer name. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
geolibre() |> add_geoparquet("https://example.com/data.parquet")geolibre() |> add_geoparquet("https://example.com/data.parquet")
Add a GeoPackage layer
add_gpkg(map, data, name = "GeoPackage", layer = NULL, ...)add_gpkg(map, data, name = "GeoPackage", layer = NULL, ...)
map |
A GeoLibre widget. |
data |
A dataset URL, a local file path, or an |
name |
Layer name. |
layer |
Optional table name inside the GeoPackage. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
geolibre() |> add_gpkg("https://example.com/data.gpkg", layer = "parcels")geolibre() |> add_gpkg("https://example.com/data.gpkg", layer = "parcels")
Add a point density heatmap
add_heatmap( map, points, name = "Heatmap", radius = 30, intensity = 1, style = list(), visible = TRUE, opacity = 1, ... )add_heatmap( map, points, name = "Heatmap", radius = 30, intensity = 1, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
points |
Points as a two-column matrix or a data frame of coordinates, a
list of |
name |
Layer name. |
radius |
Heatmap kernel radius in pixels. |
intensity |
Heatmap intensity multiplier. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_heatmap(list(c(-77, 39), c(-77.05, 39.02)), radius = 40) stopifnot(map$x$project$layers[[1]]$style$pointRenderer == "heatmap")map <- geolibre() |> add_heatmap(list(c(-77, 39), c(-77.05, 39.02)), radius = 40) stopifnot(map$x$project$layers[[1]]$style$pointRenderer == "heatmap")
Add a KML or KMZ layer
add_kml(map, data, name = "KML", ...)add_kml(map, data, name = "KML", ...)
map |
A GeoLibre widget. |
data |
A dataset URL, a local file path, or an |
name |
Layer name. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
geolibre() |> add_kml("https://example.com/places.kml")geolibre() |> add_kml("https://example.com/places.kml")
Supply the legend entries exactly one of three ways: a built-in preset
(builtin), a named vector or list of label-to-color pairs (legend), or
parallel labels and colors vectors. Each call adds another legend, so a
map can carry several at once.
add_legend( map, title = NULL, legend = NULL, labels = NULL, colors = NULL, builtin = NULL, position = c("bottom-left", "bottom-right", "top-left", "top-right"), shape = c("square", "circle", "line") )add_legend( map, title = NULL, legend = NULL, labels = NULL, colors = NULL, builtin = NULL, position = c("bottom-left", "bottom-right", "top-left", "top-right"), shape = c("square", "circle", "line") )
map |
A GeoLibre widget. |
title |
Legend title. Defaults to |
legend |
A named vector or list mapping label to CSS color. Order is preserved. |
labels |
Item labels, paired position-wise with |
colors |
Item CSS colors, paired position-wise with |
builtin |
A built-in preset name from |
position |
Corner for the legend: |
shape |
Swatch shape for every item: |
The modified widget.
add_colorbar() for continuous rasters, builtin_legend_names()
map <- geolibre() |> add_legend( "Land cover", legend = c(Water = "#466b9f", Forest = "#1c5f2c"), position = "bottom-left" ) # A built-in preset carries its own title and colors. geolibre() |> add_legend(builtin = "nlcd")map <- geolibre() |> add_legend( "Land cover", legend = c(Water = "#466b9f", Forest = "#1c5f2c"), position = "bottom-left" ) # A built-in preset carries its own title and colors. geolibre() |> add_legend(builtin = "nlcd")
Add a single point marker
add_marker( map, lng, lat, name = "Marker", properties = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_marker( map, lng, lat, name = "Marker", properties = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
lng |
Marker longitude. |
lat |
Marker latitude. |
name |
Layer name. |
properties |
Optional named list of feature properties, shown when the point is clicked. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_marker(-77.0369, 38.9072, name = "DC", circleRadius = 10)map <- geolibre() |> add_marker(-77.0369, 38.9072, name = "DC", circleRadius = 10)
Builds a point layer with the cluster renderer enabled, so nearby points collapse into count bubbles that split apart as the map zooms in.
add_marker_cluster( map, points, name = "Marker Cluster", cluster_radius = 50, cluster_max_zoom = 14, style = list(), visible = TRUE, opacity = 1, ... )add_marker_cluster( map, points, name = "Marker Cluster", cluster_radius = 50, cluster_max_zoom = 14, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
points |
Points as a two-column matrix or a data frame of coordinates, a
list of |
name |
Layer name. |
cluster_radius |
Cluster radius in pixels. |
cluster_max_zoom |
Zoom level beyond which points are no longer clustered. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_marker_cluster(list(c(-77, 39), c(-77.1, 39.1)), cluster_radius = 60) stopifnot(map$x$project$layers[[1]]$style$pointRenderer == "cluster")map <- geolibre() |> add_marker_cluster(list(c(-77, 39), c(-77.1, 39.1)), cluster_radius = 60) stopifnot(map$x$project$layers[[1]]$style$pointRenderer == "cluster")
Add point markers
add_markers( map, points, name = "Markers", style = list(), visible = TRUE, opacity = 1, ... )add_markers( map, points, name = "Markers", style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
points |
Points as a two-column matrix or a data frame of coordinates, a
list of |
name |
Layer name. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
add_circle_markers(), add_marker_cluster(), add_heatmap()
map <- geolibre() |> add_markers(list(c(-77.0369, 38.9072), c(-74.006, 40.7128)), name = "Cities") stopifnot(length(map$x$project$layers[[1]]$geojson$features) == 2L)map <- geolibre() |> add_markers(list(c(-77.0369, 38.9072), c(-74.006, 40.7128)), name = "Cities") stopifnot(length(map$x$project$layers[[1]]$geojson$features) == 2L)
The application registers the pmtiles:// protocol itself, so a plain
https:// URL to the archive is what this expects.
add_pmtiles( map, url, name = "PMTiles", tile_type = c("vector", "raster"), source_layers = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_pmtiles( map, url, name = "PMTiles", tile_type = c("vector", "raster"), source_layers = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
url |
URL of the |
name |
Layer name. |
tile_type |
|
source_layers |
Vector source layer names to render. Vector tiles only. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_pmtiles("https://example.com/data.pmtiles", source_layers = "buildings") stopifnot(map$x$project$layers[[1]]$type == "pmtiles")map <- geolibre() |> add_pmtiles("https://example.com/data.pmtiles", source_layers = "buildings") stopifnot(map$x$project$layers[[1]]$type == "pmtiles")
add_cog() with a generic default layer name.
add_raster( map, url, name = "Raster", bands = NULL, colormap = NULL, rescale = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_raster( map, url, name = "Raster", bands = NULL, colormap = NULL, rescale = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
url |
Public HTTP(S) URL of a Cloud Optimized GeoTIFF or GeoTIFF. |
name |
Layer name. |
bands |
Optional one-based band indices. Three or more bands render as
RGB; one renders as a single band, which |
colormap |
Optional GeoLibre colormap name for single-band rendering. |
rescale |
Optional list of numeric |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_raster("https://example.com/image.tif", bands = c(1, 2, 3)) stopifnot(map$x$project$layers[[1]]$type == "cog")map <- geolibre() |> add_raster("https://example.com/image.tif", bands = c(1, 2, 3)) stopifnot(map$x$project$layers[[1]]$type == "cog")
sf object to a GeoLibre mapThe object is transformed to EPSG:4326 before serialization. An object with no CRS is taken to be in longitude/latitude order already, since that is what GeoJSON means.
add_sf( map, data, name = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_sf( map, data, name = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
data |
An |
name |
Layer name. Defaults to the expression passed as |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
if (requireNamespace("sf", quietly = TRUE)) { point <- sf::st_sf( name = "Washington, DC", geometry = sf::st_sfc(sf::st_point(c(-77.0369, 38.9072)), crs = 4326) ) map <- geolibre() |> add_sf(point, name = "Places") }if (requireNamespace("sf", quietly = TRUE)) { point <- sf::st_sf( name = "Washington, DC", geometry = sf::st_sfc(sf::st_point(c(-77.0369, 38.9072)), crs = 4326) ) map <- geolibre() |> add_sf(point, name = "Places") }
Add a Shapefile layer
add_shp(map, data, name = "Shapefile", ...)add_shp(map, data, name = "Shapefile", ...)
map |
A GeoLibre widget. |
data |
A zipped Shapefile URL, or a local |
name |
Layer name. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
geolibre() |> add_shp("https://example.com/data.zip")geolibre() |> add_shp("https://example.com/data.zip")
Add an XYZ raster tile layer
add_tile_layer( map, url, name = "Tile Layer", tile_size = 256, attribution = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_tile_layer( map, url, name = "Tile Layer", tile_size = 256, attribution = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
url |
An XYZ tile URL template containing |
name |
Layer name. |
tile_size |
Tile size in pixels, typically 256. |
attribution |
Optional attribution string. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_tile_layer( "https://tile.openstreetmap.org/{z}/{x}/{y}.png", name = "OpenStreetMap", attribution = "OpenStreetMap contributors" ) stopifnot(map$x$project$layers[[1]]$type == "xyz")map <- geolibre() |> add_tile_layer( "https://tile.openstreetmap.org/{z}/{x}/{y}.png", name = "OpenStreetMap", attribution = "OpenStreetMap contributors" ) stopifnot(map$x$project$layers[[1]]$type == "xyz")
A remote URL is handed to the application's in-browser vector control, so any
format it reads (GeoParquet, FlatGeobuf, zipped Shapefile, GeoPackage,
GeoJSON, KML, ...) streams without being inlined in the project. A local file
is read with sf and inlined as GeoJSON, since the browser cannot reach a
file on this machine.
add_vector( map, data, name = "Vector", render_mode = c("geojson", "tiles"), data_format = NULL, source_layer = NULL, picker = NULL, ingest_mode = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_vector( map, data, name = "Vector", render_mode = c("geojson", "tiles"), data_format = NULL, source_layer = NULL, picker = NULL, ingest_mode = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
data |
A dataset URL, a local file path, or an |
name |
Layer name. |
render_mode |
|
data_format |
Optional format hint for remote URLs, for example
|
source_layer |
Optional layer or table name inside a multi-layer container such as a GeoPackage. |
picker |
Optional toggle for the control's feature-inspection popup. |
ingest_mode |
Optional ingest strategy, |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_vector("https://example.com/data.parquet", name = "Parcels") stopifnot(map$x$project$layers[[1]]$metadata$sourceKind == "maplibre-gl-vector")map <- geolibre() |> add_vector("https://example.com/data.parquet", name = "Parcels") stopifnot(map$x$project$layers[[1]]$metadata$sourceKind == "maplibre-gl-vector")
Add a vector tile layer from a TileJSON endpoint
add_vector_tiles( map, url, name = "Vector Tiles", source_layers = NULL, source_layer = NULL, style = list(), visible = TRUE, opacity = 1, ... )add_vector_tiles( map, url, name = "Vector Tiles", source_layers = NULL, source_layer = NULL, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
url |
TileJSON endpoint for the vector tileset. |
name |
Layer name. |
source_layers |
Source layer names to render, for multi-layer tilesets. |
source_layer |
A single source layer name, for the common single-layer
case. Ignored when |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_vector_tiles("https://example.com/tiles.json", source_layer = "roads") stopifnot(map$x$project$layers[[1]]$type == "vector-tiles")map <- geolibre() |> add_vector_tiles("https://example.com/tiles.json", source_layer = "roads") stopifnot(map$x$project$layers[[1]]$type == "vector-tiles")
Add a georeferenced video layer
add_video( map, urls, coordinates, name = "Video", style = list(), visible = TRUE, opacity = 1, ... )add_video( map, urls, coordinates, name = "Video", style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
urls |
One video URL, or several as format fallbacks such as MP4 then
WebM. URLs must be |
coordinates |
Four |
name |
Layer name. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_video( "https://example.com/clip.mp4", coordinates = list( c(-77.1, 39.0), c(-77.0, 39.0), c(-77.0, 38.9), c(-77.1, 38.9) ) ) stopifnot(map$x$project$layers[[1]]$type == "video")map <- geolibre() |> add_video( "https://example.com/clip.mp4", coordinates = list( c(-77.1, 39.0), c(-77.0, 39.0), c(-77.0, 38.9), c(-77.1, 38.9) ) ) stopifnot(map$x$project$layers[[1]]$type == "video")
The GetFeature response is fetched and inlined into the project, so the
endpoint must be able to return GeoJSON. This function contacts the service
when called.
add_wfs( map, endpoint, type_name, name = "WFS Layer", version = "2.0.0", output_format = "application/json", srs_name = "EPSG:4326", max_features = 1000, style = list(), visible = TRUE, opacity = 1, ... )add_wfs( map, endpoint, type_name, name = "WFS Layer", version = "2.0.0", output_format = "application/json", srs_name = "EPSG:4326", max_features = 1000, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
endpoint |
WFS service endpoint. |
type_name |
WFS feature type name, for example |
name |
Layer name. |
version |
WFS protocol version, for example |
output_format |
Requested output format; must yield GeoJSON. |
srs_name |
Spatial reference of the response. |
max_features |
Cap on the number of returned features, since the response
is inlined. Pass |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
## Not run: geolibre() |> add_wfs("https://ahocevar.com/geoserver/wfs", type_name = "topp:states") ## End(Not run)## Not run: geolibre() |> add_wfs("https://ahocevar.com/geoserver/wfs", type_name = "topp:states") ## End(Not run)
The layer is rendered as tiled raster from WMS GetMap requests, built
exactly as the application's Add Data dialog builds them.
add_wms( map, endpoint, layers, name = "WMS Layer", styles = "", image_format = "image/png", transparent = TRUE, tile_size = 256, version = "1.1.1", style = list(), visible = TRUE, opacity = 1, ... )add_wms( map, endpoint, layers, name = "WMS Layer", styles = "", image_format = "image/png", transparent = TRUE, tile_size = 256, version = "1.1.1", style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
endpoint |
WMS service endpoint, the |
layers |
Comma-separated WMS layer name(s). |
name |
Layer name. |
styles |
Comma-separated WMS style name(s); empty for the server default. |
image_format |
WMS image format, for example |
transparent |
Whether to request transparent tiles. |
tile_size |
Tile size in pixels. |
version |
WMS protocol version, |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_wms( "https://example.com/geoserver/wms", layers = "topp:states", name = "States" ) stopifnot(map$x$project$layers[[1]]$type == "wms")map <- geolibre() |> add_wms( "https://example.com/geoserver/wms", layers = "topp:states", name = "States" ) stopifnot(map$x$project$layers[[1]]$type == "wms")
Add a WMTS layer
add_wmts( map, url, name = "WMTS Layer", tile_size = 256, style = list(), visible = TRUE, opacity = 1, ... )add_wmts( map, url, name = "WMTS Layer", tile_size = 256, style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
url |
A WMTS tile URL template in WMTS REST |
name |
Layer name. |
tile_size |
Tile size in pixels. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
map <- geolibre() |> add_wmts("https://example.com/wmts/layer/{z}/{y}/{x}.png", name = "Imagery") stopifnot(map$x$project$layers[[1]]$type == "wmts")map <- geolibre() |> add_wmts("https://example.com/wmts/layer/{z}/{y}/{x}.png", name = "Imagery") stopifnot(map$x$project$layers[[1]]$type == "wmts")
Add points from tabular longitude and latitude columns
add_xy_data( map, data, x = "longitude", y = "latitude", name = "XY Data", style = list(), visible = TRUE, opacity = 1, ... )add_xy_data( map, data, x = "longitude", y = "latitude", name = "XY Data", style = list(), visible = TRUE, opacity = 1, ... )
map |
A GeoLibre widget. |
data |
A data frame, a CSV file path, a CSV URL, CSV text, or a list of row lists. |
x |
Name of the longitude column. |
y |
Name of the latitude column. |
name |
Layer name. |
style |
Named list of GeoLibre style overrides such as |
visible |
Whether the layer is initially visible. |
opacity |
Layer opacity from zero to one. |
... |
Additional style overrides given as named arguments, merged into
|
The modified widget.
cities <- data.frame( name = c("Washington", "New York"), longitude = c(-77.0369, -74.006), latitude = c(38.9072, 40.7128) ) map <- geolibre() |> add_xy_data(cities, name = "Cities") stopifnot(length(map$x$project$layers[[1]]$geojson$features) == 2L)cities <- data.frame( name = c("Washington", "New York"), longitude = c(-77.0369, -74.006), latitude = c(38.9072, 40.7128) ) map <- geolibre() |> add_xy_data(cities, name = "Cities") stopifnot(length(map$x$project$layers[[1]]$geojson$features) == 2L)
Lists the vector basemap styles that set_basemap() and geolibre() accept
by name. Raster tile basemaps such as OpenStreetMap are added as layers with
add_tile_layer() instead.
basemaps()basemaps()
A named character vector mapping basemap name to MapLibre style URL.
basemaps() names(basemaps())basemaps() names(basemaps())
The preset names accepted by the builtin argument of add_legend().
builtin_legend_names()builtin_legend_names()
A character vector of preset names.
builtin_legend_names()builtin_legend_names()
Symbolize an existing layer as a choropleth
classify_layer( map, layer, column, class_count = 5, colormap = "viridis", scheme = c("equal-interval", "quantile") )classify_layer( map, layer, column, class_count = 5, colormap = "viridis", scheme = c("equal-interval", "quantile") )
map |
A GeoLibre widget. |
layer |
A layer id or layer name. The layer must carry inlined GeoJSON. |
column |
Name of the numeric feature property to classify. |
class_count |
Number of classes, clamped to between 2 and 12. |
colormap |
A color ramp name from |
scheme |
Classification scheme, |
The modified widget.
add_choropleth() to add and symbolize in one call.
counties <- list( type = "FeatureCollection", features = list( list( type = "Feature", properties = list(pop = 10), geometry = list(type = "Point", coordinates = c(-77, 39)) ), list( type = "Feature", properties = list(pop = 90), geometry = list(type = "Point", coordinates = c(-76, 40)) ) ) ) map <- geolibre() |> add_geojson(counties, name = "Counties") |> classify_layer("Counties", "pop", colormap = "reds") stopifnot(map$x$project$layers[[1]]$style$vectorStyleProperty == "pop")counties <- list( type = "FeatureCollection", features = list( list( type = "Feature", properties = list(pop = 10), geometry = list(type = "Point", coordinates = c(-77, 39)) ), list( type = "Feature", properties = list(pop = 90), geometry = list(type = "Point", coordinates = c(-76, 40)) ) ) ) map <- geolibre() |> add_geojson(counties, name = "Counties") |> classify_layer("Counties", "pop", colormap = "reds") stopifnot(map$x$project$layers[[1]]$style$vectorStyleProperty == "pop")
Remove every layer
clear_layers(map)clear_layers(map)
map |
A GeoLibre widget. |
The modified widget.
map <- geolibre() |> add_marker(-77, 39) |> clear_layers() stopifnot(length(map$x$project$layers) == 0L)map <- geolibre() |> add_marker(-77, 39) |> clear_layers() stopifnot(length(map$x$project$layers) == 0L)
The ramp names accepted by add_choropleth(), classify_layer(), and
add_colorbar().
color_ramp_names()color_ramp_names()
A character vector of ramp names.
color_ramp_names()color_ramp_names()
Read one feature property across a layer
column_values(x, layer, column)column_values(x, layer, column)
x |
A GeoLibre widget or a project list. |
layer |
A layer id or layer name. |
column |
The feature property name. |
A list of the raw values, one per feature, with NULL where the
property is absent.
point <- list( type = "Feature", properties = list(pop = 700000), geometry = list(type = "Point", coordinates = c(-77, 39)) ) map <- geolibre() |> add_geojson(point, name = "Places") column_values(map, "Places", "pop")point <- list( type = "Feature", properties = list(pop = 700000), geometry = list(type = "Point", coordinates = c(-77, 39)) ) map <- geolibre() |> add_geojson(point, name = "Places") column_values(map, "Places", "pop")
Reports the camera, basemap, layers, and active map controls. URLs come back with their credentials stripped, since several basemap providers put an API key in the style URL itself.
describe_project(project)describe_project(project)
project |
A GeoLibre widget or a project list. |
A list with the project name, version, mapView,
basemapStyleUrl, layerCount, a layers data frame, and the names of the
active mapControls.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> add_legend(legend = c(Pin = "#3b82f6")) summary <- describe_project(map) summary$layerCount summary$mapControlsmap <- geolibre() |> add_marker(-77, 39, name = "Pin") |> add_legend(legend = c(Pin = "#3b82f6")) summary <- describe_project(map) summary$layerCount summary$mapControls
The copy is appended to the top of the draw order, where a newly added layer
lands. Use move_layer() to put it elsewhere.
duplicate_layer(map, layer, name = NULL)duplicate_layer(map, layer, name = NULL)
map |
A GeoLibre widget. |
layer |
A layer id or layer name. |
name |
Name for the copy. Defaults to the source name followed by
|
The modified widget.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> duplicate_layer("Pin") stopifnot(layer_names(map)[[2]] == "Pin copy")map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> duplicate_layer("Pin") stopifnot(layer_names(map)[[2]] == "Pin copy")
Position of a layer in the draw order
find_layer_index(x, name)find_layer_index(x, name)
x |
A GeoLibre widget or a project list. |
name |
A layer id or layer name. |
The one-based index of the first matching layer, or -1 when none
matches. Unlike the functions that modify a layer, a name several layers
share resolves to the first of them rather than raising.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") find_layer_index(map, "Pin") find_layer_index(map, "Missing")map <- geolibre() |> add_marker(-77, 39, name = "Pin") find_layer_index(map, "Pin") find_layer_index(map, "Missing")
A saved project records a center and zoom rather than a box to fit: the
application applies mapView$center and mapView$zoom verbatim when it opens
a project. So the box is resolved to a camera here, using an assumed viewport,
and recorded alongside it for reference. The result is approximate by
construction; expect the application's own "zoom to layer" to land within
roughly half a zoom level.
fit_bounds(map, bbox, padding = 40)fit_bounds(map, bbox, padding = 40)
map |
A GeoLibre widget. |
bbox |
|
padding |
Pixels of margin to leave around the box. |
The modified widget.
map <- geolibre() |> fit_bounds(c(-125, 24, -66, 50)) round(map$x$project$mapView$zoom, 1)map <- geolibre() |> fit_bounds(c(-125, 24, -66, 50)) round(map$x$project$mapView$zoom, 1)
Creates an htmlwidget that embeds the GeoLibre geographic information
system. The widget carries a .geolibre.json project, which the add_*(),
set_*(), and control functions build up with the pipe.
geolibre( project = NULL, center = NULL, zoom = NULL, basemap = NULL, name = "Untitled Project", width = NULL, height = NULL, app_url = getOption("geolibre.app_url", "https://web.geolibre.app/"), layout = c("embed", "full", "maponly"), theme = c("light", "dark"), map_only = FALSE, elementId = NULL, panels = c("expanded", "collapsed", "hidden") )geolibre( project = NULL, center = NULL, zoom = NULL, basemap = NULL, name = "Untitled Project", width = NULL, height = NULL, app_url = getOption("geolibre.app_url", "https://web.geolibre.app/"), layout = c("embed", "full", "maponly"), theme = c("light", "dark"), map_only = FALSE, elementId = NULL, panels = c("expanded", "collapsed", "hidden") )
project |
A GeoLibre project list, a path to a |
center |
Optional initial |
zoom |
Optional initial zoom level. |
basemap |
Optional basemap name from |
name |
Project name recorded in the project file. |
width, height
|
Widget dimensions passed to |
app_url |
URL of a GeoLibre web deployment. It must support the
|
layout |
Application chrome to show: |
theme |
Application theme, |
map_only |
Deprecated. |
elementId |
Optional widget element ID. |
panels |
Initial side-panel state: |
The default hosted application requires internet access when the
widget is displayed. Package installation, project construction, and file
operations do not contact it. Set app_url or the geolibre.app_url
option to use a self-hosted deployment.
An htmlwidget that can be modified with add_*() functions.
add_geojson(), set_view(), save_project()
map <- geolibre(center = c(-77.0369, 38.9072), zoom = 10, layout = "maponly") stopifnot(inherits(map, "geolibre")) # A dark-themed map with the full application interface. geolibre(basemap = "dark", layout = "full")map <- geolibre(center = c(-77.0369, 38.9072), zoom = 10, layout = "maponly") stopifnot(inherits(map, "geolibre")) # A dark-themed map with the full application interface. geolibre(basemap = "dark", layout = "full")
The escape hatch behind the geolibre_*() command functions: it forwards any
method the application's scripting bridge implements. The reply arrives
asynchronously on the input$id_result input described in geolibreOutput().
geolibre_command(proxy, method, params = list(), request_id = NULL)geolibre_command(proxy, method, params = list(), request_id = NULL)
proxy |
A GeoLibre proxy created by |
method |
The scripting method name, for example |
params |
Named list of parameters for the method. |
request_id |
Optional id echoed back with the reply, so several in-flight commands can be told apart. Generated when omitted. |
The proxy, invisibly.
geolibre_fly_to(), geolibre_get_view(), geolibre_run_algorithm()
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_command(geolibre_proxy("map"), "zoomToLayer", list(layerId = "abc")) }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_command(geolibre_proxy("map"), "zoomToLayer", list(layerId = "abc")) }
Fit a live GeoLibre map to a bounding box
geolibre_fit_bounds(proxy, bbox, request_id = NULL)geolibre_fit_bounds(proxy, bbox, request_id = NULL)
proxy |
A GeoLibre proxy created by |
bbox |
|
request_id |
Optional id echoed back with the reply. |
The proxy, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_fit_bounds(geolibre_proxy("map"), c(-125, 24, -66, 50)) }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_fit_bounds(geolibre_proxy("map"), c(-125, 24, -66, 50)) }
Unlike set_view(), which records the camera a project opens at, this
animates the map that is already on screen. Omitted fields keep their current
value.
geolibre_fly_to( proxy, center = NULL, zoom = NULL, bearing = NULL, pitch = NULL, duration = NULL, request_id = NULL )geolibre_fly_to( proxy, center = NULL, zoom = NULL, bearing = NULL, pitch = NULL, duration = NULL, request_id = NULL )
proxy |
A GeoLibre proxy created by |
center |
Optional |
zoom |
Optional target zoom level. |
bearing |
Optional target bearing in degrees. |
pitch |
Optional target pitch in degrees. |
duration |
Optional animation duration in milliseconds. |
request_id |
Optional id echoed back with the reply. |
The proxy, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_fly_to(geolibre_proxy("map"), center = c(-77.0369, 38.9072), zoom = 12) }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_fly_to(geolibre_proxy("map"), center = c(-77.0369, 38.9072), zoom = 12) }
The reply arrives on input$id_result with a value holding center, zoom,
bearing, pitch, and the current bbox.
geolibre_get_view(proxy, request_id = NULL)geolibre_get_view(proxy, request_id = NULL)
proxy |
A GeoLibre proxy created by |
request_id |
Optional id echoed back with the reply. |
The proxy, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_get_view(geolibre_proxy("map")) }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_get_view(geolibre_proxy("map")) }
Identify features at a point on a live GeoLibre map
geolibre_identify(proxy, lnglat, layer_id = NULL, request_id = NULL)geolibre_identify(proxy, lnglat, layer_id = NULL, request_id = NULL)
proxy |
A GeoLibre proxy created by |
lnglat |
|
layer_id |
Optional layer id to restrict the query to. |
request_id |
Optional id echoed back with the reply. |
The proxy, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_identify(geolibre_proxy("map"), c(-77.0369, 38.9072)) }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_identify(geolibre_proxy("map"), c(-77.0369, 38.9072)) }
geolibre_layer_features() returns one layer's features,
geolibre_selected_features() the current selection, and
geolibre_drawn_features() whatever the user drew with the map's editing
tools. Each reply arrives on input$id_result.
geolibre_layer_features(proxy, layer_id, request_id = NULL) geolibre_selected_features(proxy, request_id = NULL) geolibre_drawn_features(proxy, request_id = NULL)geolibre_layer_features(proxy, layer_id, request_id = NULL) geolibre_selected_features(proxy, request_id = NULL) geolibre_drawn_features(proxy, request_id = NULL)
proxy |
A GeoLibre proxy created by |
layer_id |
The layer's id, as reported by |
request_id |
Optional id echoed back with the reply. |
The proxy, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_drawn_features(geolibre_proxy("map")) }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_drawn_features(geolibre_proxy("map")) }
A proxy addresses a widget that is already on screen, so a Shiny app can
replace its project with update_geolibre() or drive the live map with the
geolibre_*() command functions, without re-rendering the widget.
geolibre_proxy(outputId, session = NULL)geolibre_proxy(outputId, session = NULL)
outputId |
ID of an existing GeoLibre widget. |
session |
A Shiny session. Defaults to the current reactive domain. |
A geolibre_proxy object.
update_geolibre(), geolibre_fly_to(), geolibre_command()
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { proxy <- geolibre_proxy("map") }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { proxy <- geolibre_proxy("map") }
geolibre_list_algorithms() reports the available tools with their
parameters; geolibre_run_algorithm() runs one in the browser. Results arrive
on input$id_result, and any output layers are added to the map.
geolibre_run_algorithm(proxy, algorithm, params = list(), request_id = NULL) geolibre_list_algorithms(proxy, request_id = NULL)geolibre_run_algorithm(proxy, algorithm, params = list(), request_id = NULL) geolibre_list_algorithms(proxy, request_id = NULL)
proxy |
A GeoLibre proxy created by |
algorithm |
The algorithm id, as reported by
|
params |
Named list of algorithm parameters. |
request_id |
Optional id echoed back with the reply. |
The proxy, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { proxy <- geolibre_proxy("map") geolibre_list_algorithms(proxy) geolibre_run_algorithm(proxy, "buffer", list(layerId = "abc", distance = 500)) }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { proxy <- geolibre_proxy("map") geolibre_list_algorithms(proxy) geolibre_run_algorithm(proxy, "buffer", list(layerId = "abc", distance = 500)) }
The reply arrives on input$id_result with a value holding a
data:image/png;base64,... URL. Strip the prefix up to the comma and pass the
rest to jsonlite::base64_dec() to recover the PNG bytes.
geolibre_to_image(proxy, request_id = NULL)geolibre_to_image(proxy, request_id = NULL)
proxy |
A GeoLibre proxy created by |
request_id |
Optional id echoed back with the reply. |
The proxy, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_to_image(geolibre_proxy("map")) }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_to_image(geolibre_proxy("map")) }
Zoom a live GeoLibre map to a layer's extent
geolibre_zoom_to_layer(proxy, layer_id, request_id = NULL)geolibre_zoom_to_layer(proxy, layer_id, request_id = NULL)
proxy |
A GeoLibre proxy created by |
layer_id |
The layer's id, as reported by |
request_id |
Optional id echoed back with the reply. |
The proxy, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_zoom_to_layer(geolibre_proxy("map"), "layer-id") }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { geolibre_zoom_to_layer(geolibre_proxy("map"), "layer-id") }
Shiny bindings for GeoLibre
geolibreOutput(outputId, width = "100%", height = "700px") renderGeolibre(expr, env = parent.frame(), quoted = FALSE)geolibreOutput(outputId, width = "100%", height = "700px") renderGeolibre(expr, env = parent.frame(), quoted = FALSE)
outputId |
Output variable to read from. |
width, height
|
Widget dimensions. |
expr |
An expression that generates a GeoLibre widget. |
env |
Environment in which to evaluate |
quoted |
Whether |
geolibreOutput() returns a Shiny output element;
renderGeolibre() returns a render function for it.
A rendered widget reports back through four inputs, where id is the
outputId:
input$id_project — the full project each time the user edits the map.
input$id_error — the message from a project the application rejected.
input$id_result — the reply to a proxy command; a list with requestId,
method, ok, and then value or error.
input$id_event — user interaction; a list with event, one of "click",
"selection-change", or "layer-change", and its payload.
if (requireNamespace("shiny", quietly = TRUE)) { output <- geolibreOutput("map", height = "500px") stopifnot(inherits(output, "shiny.tag.list")) }if (requireNamespace("shiny", quietly = TRUE)) { output <- geolibreOutput("map", height = "500px") stopifnot(inherits(output, "shiny.tag.list")) }
Anchor colors of a color ramp
get_color_ramp(name = "viridis")get_color_ramp(name = "viridis")
name |
A ramp name from |
A character vector of #rrggbb colors.
get_color_ramp("viridis") get_color_ramp("blues")get_color_ramp("viridis") get_color_ramp("blues")
Read one layer's full definition
get_layer(x, layer)get_layer(x, layer)
x |
A GeoLibre widget or a project list. |
layer |
A layer id or layer name. |
The layer as a list, with credential-bearing fields stripped.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") get_layer(map, "Pin")$typemap <- geolibre() |> add_marker(-77, 39, name = "Pin") get_layer(map, "Pin")$type
Summarize a project's layers
get_layers(x)get_layers(x)
x |
A GeoLibre widget or a project list. |
A data frame with one row per layer, in draw order, holding its id,
name, type, visible, opacity, source URL (credentials stripped),
and inlined features count.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> add_raster("https://example.com/image.tif", name = "Image") get_layers(map)map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> add_raster("https://example.com/image.tif", name = "Image") get_layers(map)
Read a project out of a widget
get_project(map, keep_credentials = FALSE)get_project(map, keep_credentials = FALSE)
map |
A GeoLibre widget or project list. |
keep_credentials |
Keep credential-bearing configuration. Defaults to
|
The project as a list.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") project <- get_project(map) project$layers[[1]]$namemap <- geolibre() |> add_marker(-77, 39, name = "Pin") project <- get_project(map) project$layers[[1]]$name
Mirrors the application's ramp interpolation, so a palette generated here matches the one the Style panel would compute.
interpolate_ramp_colors(name = "viridis", count = 5)interpolate_ramp_colors(name = "viridis", count = 5)
name |
A ramp name from |
count |
Number of colors to produce. |
A character vector of count #rrggbb colors.
interpolate_ramp_colors("viridis", 5)interpolate_ramp_colors("viridis", 5)
Layer names in draw order
layer_names(x)layer_names(x)
x |
A GeoLibre widget or a project list. |
A character vector of layer names, bottom layer first.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") layer_names(map)map <- geolibre() |> add_marker(-77, 39, name = "Pin") layer_names(map)
Lets you discover what an inlined vector layer can be styled or filtered by without reading every feature back.
layer_properties(x, layer)layer_properties(x, layer)
x |
A GeoLibre widget or a project list. |
layer |
A layer id or layer name. |
A named list mapping each property name to up to 25 distinct sample values, in first-seen order.
point <- list( type = "Feature", properties = list(name = "DC", pop = 700000), geometry = list(type = "Point", coordinates = c(-77, 39)) ) map <- geolibre() |> add_geojson(point, name = "Places") layer_properties(map, "Places")point <- list( type = "Feature", properties = list(name = "DC", pop = 700000), geometry = list(type = "Point", coordinates = c(-77, 39)) ) map <- geolibre() |> add_geojson(point, name = "Places") layer_properties(map, "Places")
Read a GeoLibre project
load_project(source)load_project(source)
source |
Path to a |
A project list.
save_project(), describe_project()
project <- load_project('{"version":"0.2.0","name":"Example","mapView":{}}') stopifnot(project$name == "Example") # A saved project can be reopened as a widget. path <- tempfile(fileext = ".geolibre.json") save_project(geolibre() |> add_marker(-77, 39), path) map <- geolibre(load_project(path))project <- load_project('{"version":"0.2.0","name":"Example","mapView":{}}') stopifnot(project$name == "Example") # A saved project can be reopened as a widget. path <- tempfile(fileext = ".geolibre.json") save_project(geolibre() |> add_marker(-77, 39), path) map <- geolibre(load_project(path))
Move a layer in the draw order
move_layer(map, layer, index)move_layer(map, layer, index)
map |
A GeoLibre widget. |
layer |
A layer id or layer name. |
index |
One-based destination position, counted from the bottom of the
draw order. Negative values count from the top, so |
The modified widget.
map <- geolibre() |> add_marker(-77, 39, name = "Bottom") |> add_marker(-76, 40, name = "Top") |> move_layer("Top", 1) stopifnot(layer_names(map)[[1]] == "Top")map <- geolibre() |> add_marker(-77, 39, name = "Bottom") |> add_marker(-76, 40, name = "Top") |> move_layer("Top", 1) stopifnot(layer_names(map)[[1]] == "Top")
Returns a project safe to publish, export, or hand to someone else: layer request headers and signed URLs, basemap style keys, geocoding keys, stored environment variables, and third-party plugin settings are all removed. The first-party map controls (legend, colorbar, swipe) are kept, since a project needs them to render as it was built.
redact_credentials(project)redact_credentials(project)
project |
A GeoLibre widget or a project list. |
save_project() applies this by default.
The project list with credentials removed.
map <- geolibre() |> add_marker(-77, 39) safe <- redact_credentials(map) safe$namemap <- geolibre() |> add_marker(-77, 39) safe <- redact_credentials(map) safe$name
Strip credentials from one layer
redact_layer(layer)redact_layer(layer)
layer |
A layer list, as returned inside a project's |
The layer with its credential-bearing configuration removed.
map <- geolibre() |> add_3d_tiles( "https://example.com/tileset.json", request_headers = list(Authorization = "Bearer secret") ) layer <- redact_layer(map$x$project$layers[[1]]) is.null(layer$source$requestHeaders)map <- geolibre() |> add_3d_tiles( "https://example.com/tileset.json", request_headers = list(Authorization = "Bearer secret") ) layer <- redact_layer(map$x$project$layers[[1]]) is.null(layer$source$requestHeaders)
Removes any user:password@ prefix and any query parameter whose name marks
it as a credential, such as api_key, access_token, or an Azure
shared-access signature. The rest of the URL is left byte-for-byte intact.
redact_url(url)redact_url(url)
url |
A URL string. |
The URL with its credentials removed.
redact_url("https://tiles.example.com/style.json?api_key=secret&lang=en") redact_url("https://user:[email protected]/data.tif")redact_url("https://tiles.example.com/style.json?api_key=secret&lang=en") redact_url("https://user:[email protected]/data.tif")
Remove a layer
remove_layer(map, layer)remove_layer(map, layer)
map |
A GeoLibre widget. |
layer |
A layer id or layer name. |
The modified widget.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> remove_layer("Pin") stopifnot(length(map$x$project$layers) == 0L)map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> remove_layer("Pin") stopifnot(length(map$x$project$layers) == 0L)
Rename a layer
rename_layer(map, layer, name)rename_layer(map, layer, name)
map |
A GeoLibre widget. |
layer |
A layer id or layer name. |
name |
The new display name. Surrounding whitespace is stripped. |
The modified widget.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> rename_layer("Pin", "Capital") stopifnot(layer_names(map) == "Capital")map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> rename_layer("Pin", "Capital") stopifnot(layer_names(map) == "Capital")
Save a GeoLibre project
save_project(map, path, keep_credentials = FALSE)save_project(map, path, keep_credentials = FALSE)
map |
A GeoLibre widget or project list. |
path |
Output path, conventionally ending in |
keep_credentials |
Keep credential-bearing configuration such as layer
request headers and signed URLs. Defaults to |
path, invisibly.
load_project(), redact_credentials()
path <- tempfile(fileext = ".geolibre.json") save_project(geolibre(), path) project <- load_project(path) stopifnot(project$name == "Untitled Project")path <- tempfile(fileext = ".geolibre.json") save_project(geolibre(), path) project <- load_project(path) stopifnot(project$name == "Untitled Project")
Set the background basemap
set_basemap(map, basemap) add_basemap(map, basemap)set_basemap(map, basemap) add_basemap(map, basemap)
map |
A GeoLibre widget. |
basemap |
A basemap name from |
The modified widget.
basemaps(), add_tile_layer() for raster basemaps such as
OpenStreetMap.
map <- geolibre() |> set_basemap("dark") map$x$project$basemapStyleUrlmap <- geolibre() |> set_basemap("dark") map$x$project$basemapStyleUrl
Set the camera bearing
set_bearing(map, bearing)set_bearing(map, bearing)
map |
A GeoLibre widget. |
bearing |
Clockwise rotation in degrees. |
The modified widget.
map <- geolibre() |> set_bearing(45) stopifnot(map$x$project$mapView$bearing == 45)map <- geolibre() |> set_bearing(45) stopifnot(map$x$project$mapView$bearing == 45)
Center the map
set_center(map, lng, lat, zoom = NULL)set_center(map, lng, lat, zoom = NULL)
map |
A GeoLibre widget. |
lng |
Longitude of the new center. |
lat |
Latitude of the new center. |
zoom |
Optional zoom level. |
The modified widget.
map <- geolibre() |> set_center(-77.0369, 38.9072, zoom = 11) stopifnot(map$x$project$mapView$zoom == 11)map <- geolibre() |> set_center(-77.0369, 38.9072, zoom = 11) stopifnot(map$x$project$mapView$zoom == 11)
Set a layer's opacity
set_layer_opacity(map, layer, opacity)set_layer_opacity(map, layer, opacity)
map |
A GeoLibre widget. |
layer |
A layer id or layer name. |
opacity |
Opacity from zero to one. |
The modified widget.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> set_layer_opacity("Pin", 0.4) stopifnot(map$x$project$layers[[1]]$opacity == 0.4)map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> set_layer_opacity("Pin", 0.4) stopifnot(map$x$project$layers[[1]]$opacity == 0.4)
Merges style overrides into a layer's existing style. Keys not mentioned keep their current values.
set_layer_style(map, layer, style = list(), ...)set_layer_style(map, layer, style = list(), ...)
map |
A GeoLibre widget. |
layer |
A layer id or layer name. |
style |
Named list of style keys to set. |
... |
Additional style overrides given as named arguments. |
The modified widget.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> set_layer_style("Pin", fillColor = "#f59e0b", circleRadius = 9) stopifnot(map$x$project$layers[[1]]$style$fillColor == "#f59e0b")map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> set_layer_style("Pin", fillColor = "#f59e0b", circleRadius = 9) stopifnot(map$x$project$layers[[1]]$style$fillColor == "#f59e0b")
Show or hide a layer
set_layer_visibility(map, layer, visible = TRUE) show_layer(map, layer) hide_layer(map, layer)set_layer_visibility(map, layer, visible = TRUE) show_layer(map, layer) hide_layer(map, layer)
map |
A GeoLibre widget. |
layer |
A layer id or layer name. |
visible |
|
The modified widget.
map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> set_layer_visibility("Pin", FALSE) stopifnot(isFALSE(map$x$project$layers[[1]]$visible))map <- geolibre() |> add_marker(-77, 39, name = "Pin") |> set_layer_visibility("Pin", FALSE) stopifnot(isFALSE(map$x$project$layers[[1]]$visible))
Set the camera pitch
set_pitch(map, pitch)set_pitch(map, pitch)
map |
A GeoLibre widget. |
pitch |
Tilt in degrees, clamped to between 0 and 85. |
The modified widget.
map <- geolibre() |> set_pitch(60) stopifnot(map$x$project$mapView$pitch == 60)map <- geolibre() |> set_pitch(60) stopifnot(map$x$project$mapView$pitch == 60)
Set the project name
set_project_name(map, name)set_project_name(map, name)
map |
A GeoLibre widget. |
name |
The project's display name, as shown in the application and stored in the project file. |
The modified widget.
map <- geolibre() |> set_project_name("Chesapeake Bay") map$x$project$namemap <- geolibre() |> set_project_name("Chesapeake Bay") map$x$project$name
Set the GeoLibre camera
set_view( map, center = NULL, zoom = NULL, bearing = NULL, pitch = NULL, bbox = NULL )set_view( map, center = NULL, zoom = NULL, bearing = NULL, pitch = NULL, bbox = NULL )
map |
A GeoLibre widget. |
center |
Optional |
zoom |
Optional zoom level, clamped to between 0 and 24. |
bearing |
Optional clockwise rotation in degrees. |
pitch |
Optional tilt in degrees, clamped to between 0 and 85. |
bbox |
Optional |
The modified widget.
fit_bounds(), set_center(), set_zoom()
map <- geolibre() |> set_view(center = c(-77.0369, 38.9072), zoom = 10, pitch = 30) stopifnot(map$x$project$mapView$zoom == 10)map <- geolibre() |> set_view(center = c(-77.0369, 38.9072), zoom = 10, pitch = 30) stopifnot(map$x$project$mapView$zoom == 10)
Set the map zoom
set_zoom(map, zoom)set_zoom(map, zoom)
map |
A GeoLibre widget. |
zoom |
Zoom level, clamped to between 0 and 24. |
The modified widget.
map <- geolibre() |> set_zoom(6) stopifnot(map$x$project$mapView$zoom == 6)map <- geolibre() |> set_zoom(6) stopifnot(map$x$project$mapView$zoom == 6)
Enables the Layer Swipe control, which clips one set of layers to one side of a draggable slider and another set to the other, for before-and-after comparisons.
split_map( map, left_layers = NULL, right_layers = NULL, orientation = c("vertical", "horizontal"), position = 50, control_position = c("top-left", "top-right", "bottom-left", "bottom-right") )split_map( map, left_layers = NULL, right_layers = NULL, orientation = c("vertical", "horizontal"), position = 50, control_position = c("top-left", "top-right", "bottom-left", "bottom-right") )
map |
A GeoLibre widget. |
left_layers |
Layer ids or names shown on the left or top of the slider.
The string |
right_layers |
Layer ids or names shown on the right or bottom. |
orientation |
|
position |
Initial slider position as a percentage from 0 to 100. |
control_position |
Corner for the swipe panel: |
The modified widget.
map <- geolibre() |> add_raster("https://example.com/before.tif", name = "Before") |> add_raster("https://example.com/after.tif", name = "After") |> split_map("Before", "After") stopifnot(length(map$x$project$plugins$settings) == 1L)map <- geolibre() |> add_raster("https://example.com/before.tif", name = "Before") |> add_raster("https://example.com/after.tif", name = "After") |> split_map("Before", "After") stopifnot(length(map$x$project$plugins$settings) == 1L)
The page embeds the GeoLibre application in an iframe and injects the
project into it over the same postMessage bridge the widget uses, so it
renders the map as configured. Unlike the widget it needs no running R
session; by default it loads the hosted application over the network so the
file stays portable.
to_html( map, path = NULL, title = "GeoLibre Map", width = "100%", height = "800px", app_url = getOption("geolibre.app_url", "https://web.geolibre.app/") )to_html( map, path = NULL, title = "GeoLibre Map", width = "100%", height = "800px", app_url = getOption("geolibre.app_url", "https://web.geolibre.app/") )
map |
A GeoLibre widget or project list. |
path |
Optional output path. When supplied the page is written there and
|
title |
The exported page's |
width |
CSS width of the embedded map, for example |
height |
CSS height of the embedded map. |
app_url |
Base URL of the GeoLibre application to embed. Defaults to the hosted viewer so the export stays portable; pass a self-hosted deployment URL to pin a specific version. |
Credentials are stripped from the inlined project on the way out, as
save_project() does.
The HTML string, or path invisibly when path is supplied.
save_project() to write the project itself
map <- geolibre() |> add_marker(-77.0369, 38.9072, name = "DC") html <- to_html(map, title = "Washington, DC") substr(html, 1, 15) path <- tempfile(fileext = ".html") to_html(map, path)map <- geolibre() |> add_marker(-77.0369, 38.9072, name = "DC") html <- to_html(map, title = "Washington, DC") substr(html, 1, 15) path <- tempfile(fileext = ".html") to_html(map, path)
Replace the project displayed by a GeoLibre Shiny widget
update_geolibre(proxy, map)update_geolibre(proxy, map)
proxy |
A GeoLibre proxy created by |
map |
A GeoLibre widget or project list. |
The proxy, invisibly.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { update_geolibre(geolibre_proxy("map"), geolibre()) }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { update_geolibre(geolibre_proxy("map"), geolibre()) }