Package 'polr'

Title: Polar OpenLayers
Description: A minimal set of bindings to the OpenLayers javascript library, with a focus on polar mapping applications.
Authors: Ben Raymond [aut, cre], Stefan Kuethe [ctb] (Author of https://github.com/crazycapivara/openlayers/, of which polr is a reimplementation and extension (of a sort)), OpenLayers contributors [ctb] (OpenLayers javascript library)
Maintainer: Ben Raymond <[email protected]>
License: MIT + file LICENSE
Version: 0.1.1
Built: 2026-06-01 07:45:27 UTC
Source: https://github.com/SCAR/polr

Help Index


Add clustered points

Description

Add clustered points

Usage

add_clustered_points(
  map,
  lon,
  lat,
  cluster_style = NULL,
  cluster_hull_style = NULL,
  marker_style = NULL,
  popup = NULL,
  cluster_options = list(distance = 10, min_distance = 0),
  ...
)

Arguments

map

pol or pol_proxy: map to add the layer to

lon

numeric: longitudes

lat

numeric: latitudes

cluster_style

: a style object as returned by pol_style() for the cluster markers, typically with components text and circle

cluster_hull_style

: a style object as returned by pol_style() for the cluster convex hulls, with components fill and stroke

marker_style

: a style object as returned by pol_style() for single markers (i.e. when a cluster has reduced to a single feature)

popup

character: popups to show, one per point

cluster_options

list: named list with components distance and min_distance (as for https://openlayers.org/en/latest/apidoc/module-ol_source_Cluster-Cluster.html)

...

: named vector layer options https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html

Value

A pol map object


Add cloud-optimised geotiff layer

Description

Add cloud-optimised geotiff layer

Usage

add_cog(map, sources, geotiff_source_options = NULL, ...)

Arguments

map

pol or pol_proxy: map to add the layer to

sources

: either a character vector of one or more URLs, or a list of pol_geotiff_source objects

geotiff_source_options

list: geotiff source options https://openlayers.org/en/latest/apidoc/module-ol_source_GeoTIFF.html#~GeoTIFFSourceOptions

...

: named webGL tile source options https://openlayers.org/en/latest/apidoc/module-ol_layer_WebGLTile.html

Value

A pol map object


Add a flatgeobuf vector layer

Description

Add a flatgeobuf vector layer

Usage

add_fgb(map, url, file, style = NULL, popup = NULL, ...)

Arguments

map

pol or pol_proxy: map to add the layer to

url

string: URL to the flatgeobuf. Ignored if file is provided

file

string: path to the flatgeobuf file. Note that file will only work with Shiny, not in standalone htmlwidgets or rmarkdown files

style

: either a style object as returned by pol_style() or a list of flat style properties https://openlayers.org/en/latest/apidoc/module-ol_style_flat.html

popup

character: popups to show, one per point

...

: named vector layer options https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html

Value

A pol map object

References

https://flatgeobuf.org/examples/openlayers/


Add a geoJSON vector layer

Description

Add a geoJSON vector layer

Usage

add_geojson(map, data, file, style = NULL, popup = NULL, data_proj = NULL, ...)

Arguments

map

pol or pol_proxy: map to add the layer to

data

string: geoJSON data as a string. Ignored if file is provided

file

string: path to geojson file

style

: either a style object as returned by pol_style() or a list of flat style properties: https://openlayers.org/en/latest/apidoc/module-ol_style_flat.html

popup

character: popups to show, one per point

data_proj

string: the projection code of the geojson data. If omitted, it will be derived from the data where possible. If it cannot, the data will not be reprojected to the map's projection

...

: named vector layer options https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html

Value

A pol map object


Add graticule

Description

Add graticule

Usage

add_graticule(
  map,
  lons = seq(-180, 150, by = 30),
  lats = seq(-90, -40, by = 10),
  nverts = 51,
  xlim = range(lons),
  ylim = range(lats),
  style = NULL,
  no_legend = TRUE,
  ...
)

Arguments

map

pol or pol_proxy: map to add the layer to

lons

numeric: longitudes for meridional lines

lats

numeric: latitudes for parallel lines

nverts

numeric: number of discrete vertices for each segment

xlim

numeric: maximum range of parallel lines

ylim

numeric: maximum range of meridional lines

style

: either a style object as returned by pol_style() or a list of flat style properties: https://openlayers.org/en/latest/apidoc/module-ol_style_flat.html

no_legend

logical: if TRUE, don't include this layer in the layer switcher legend

...

: named vector layer options https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html

Value

A pol map object

See Also

graticule::graticule()


Add layer switcher

Description

Add layer switcher

Usage

add_layer_switcher(map, target_id)

Arguments

map

pol or pol_proxy: map to add the layer switcher to

target_id

string: ID of the html element to add the switcher to. If missing, the switcher will be placed inside the map pane

Value

A pol map object


Add points

Description

Add points

Usage

add_points(map, lon, lat, style = NULL, popup = NULL, ...)

Arguments

map

pol or pol_proxy: map to add the layer to

lon

numeric: longitudes

lat

numeric: latitudes

style

: either a style object as returned by pol_style() or a list of flat style properties: https://openlayers.org/en/latest/apidoc/module-ol_style_flat.html

popup

character: popups to show, one per point

...

: named vector layer options https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html

Value

A pol map object


Add WMS tile layer to a map

Description

Add WMS tile layer to a map

Usage

add_wms_tiles(
  map,
  url,
  layers,
  wms_params = NULL,
  tile_wms_options = list(),
  ...
)

Arguments

map

pol or pol_proxy: map to add the layer to

url

string: URL to the WMS server

layers

character: WMS layer names to include

wms_params

list: params of https://openlayers.org/en/latest/apidoc/module-ol_source_TileWMS-TileWMS.html. The LAYERS, TILED, and some other elements are set automatically

tile_wms_options

list: https://openlayers.org/en/latest/apidoc/module-ol_source_TileWMS-TileWMS.html

...

: named tile layer options https://openlayers.org/en/latest/apidoc/module-ol_layer_Tile-TileLayer.html

Value

A pol map object


Add WMTS tile layer to a map from a WMTS server capabilities endpoint

Description

Add WMTS tile layer to a map from a WMTS server capabilities endpoint

Usage

add_wmts_from_capabilities(map, url, layer, wmts_options = list(), ...)

Arguments

map

pol or pol_proxy: map to add the layer to

url

string: URL to the WMTSCapabilities.xml document

layer

string: layer name

wmts_options

named list: other WMTS options as per https://openlayers.org/en/latest/apidoc/module-ol_source_WMTS.html#.optionsFromCapabilities

...

: named options as per https://openlayers.org/en/latest/apidoc/module-ol_layer_Tile-TileLayer.html

Value

A pol map object


Create a polar OpenLayers map object

Description

Create a polar OpenLayers map object

Usage

pol(
  view_options = list(),
  control_options = list(zoom = TRUE, rotate = FALSE),
  width = NULL,
  height = NULL,
  elementId = NULL
)

Arguments

view_options

list: https://openlayers.org/en/latest/apidoc/module-ol_View.html#~ViewOptions. By default the projection will be set to "EPSG:3031" (Antarctic polar stereographic)

control_options

list: https://openlayers.org/en/latest/apidoc/module-ol_control_defaults.html#~DefaultsOptions

width, height

: Must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended

elementId

string: element ID


Create a colour palette to use with a raster

Description

Create a colour palette to use with a raster

Usage

pol_colourmap(col, range = c(0, 1), breaks, with_nodata = TRUE)

pol_colormap(col, range = c(0, 1), breaks, with_nodata = TRUE)

Arguments

col

character: vector of hex colour strings

range

numeric: data range, noting that by default a layer's values are scaled to the range 0-1

breaks

numeric: optional vector of breaks, same length as col. If not provided, breaks will be equally spaced across range

with_nodata

logical: if TRUE, the layer's "nodata" (missing) value will be shown as transparent

Value

An object of class pol_colourmap


Create a geotiff source

Description

Provides an alternative way of specifying a geotiff source to use in add_cog(), giving more control beyond just the source URL.

Usage

pol_geotiff_source(url, overviews, min, max, nodata, bands)

Arguments

url

string: URL

overviews

character: overview URLs

min

numeric: minimum source data value

max

numeric: maximum source data value

nodata

numeric: the source data value representing "no data"

bands

numeric: band numbers to be read from (numbered starting from 1)

Value

An object of class pol_geotiff_source

References

https://openlayers.org/en/latest/apidoc/module-ol_source_GeoTIFF.html#~SourceInfo


Modify a pol object inside a Shiny app

Description

Modify a pol object inside a Shiny app

Usage

pol_proxy(
  outputId,
  session = shiny::getDefaultReactiveDomain(),
  deferUntilFlush = TRUE
)

Arguments

outputId

string: the ID of the map

session

the Shiny session object to which the map belongs; usually the default value will suffice.

deferUntilFlush

logical: if TRUE then wait until the outputs are next updated to apply changes to the map


Style

Description

Style

Usage

pol_style(
  fill = NULL,
  image = NULL,
  icon = NULL,
  shape = NULL,
  circle = NULL,
  stroke = NULL,
  text = NULL,
  z_index = NULL
)

Arguments

fill

list: https://openlayers.org/en/latest/apidoc/module-ol_style_Fill-Fill.html

image

list: https://openlayers.org/en/latest/apidoc/module-ol_style_Image-ImageStyle.html

icon

list: https://openlayers.org/en/latest/apidoc/module-ol_style_Icon-Icon.html

shape

list: https://openlayers.org/en/latest/apidoc/module-ol_style_RegularShape-RegularShape.html

circle

list: https://openlayers.org/en/latest/apidoc/module-ol_style_Circle-CircleStyle.html

stroke

list: https://openlayers.org/en/latest/apidoc/module-ol_style_Stroke-Stroke.html

text

list: https://openlayers.org/en/latest/apidoc/module-ol_style_Text-Text.html

z_index

integer: z index

Value

An oject of class pol_style

References

https://openlayers.org/en/latest/apidoc/module-ol_style_Style.html

See Also

add_geojson()

Examples

mystyle <- pol_style(stroke = list(color = "green"))

Shiny bindings for pol

Description

Output and render functions for using pol within Shiny applications and interactive Rmd documents.

Usage

polOutput(outputId, width = "100%", height = "400px")

renderPol(expr, env = parent.frame(), quoted = FALSE)

Arguments

outputId

output variable to read from

width, height

Must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended.

expr

An expression that generates a pol

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.


polr

Description

A minimal set of bindings to the OpenLayers javascript library, with a focus on polar mapping applications.

Author(s)

Maintainer: Ben Raymond [email protected]

Other contributors:

  • Stefan Kuethe [email protected] (Author of https://github.com/crazycapivara/openlayers/, of which polr is a reimplementation and extension (of a sort)) [contributor]

  • OpenLayers contributors (OpenLayers javascript library) [contributor]

See Also

Useful links:


Remove a layer

Description

Remove a layer

Usage

remove_layer(map, layer_name)

Arguments

map

pol or pol_proxy: map to remove the layer from

layer_name

string: name of the layer. layer_name must have been provided when adding the layer (e.g. along the lines of add_wms_tiles(..., name = "My Layer"))

Value

A pol map object