Description Usage Arguments Examples
This function creates static or interactive maps (choropleth, pointmap or heatmap) from geospatial and attribute data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
data |
Input data for plotting; must be a simple features (sf) shape object, e.g., imported by geo_import(). REQUIRED. (Note: if input data contains invalid geometries, a warning will be provided and the geometries will be automatically fixed prior to plotting) |
geography_col |
Name of the data column containing the feature, e.g., geographic units, population size, etc., to be plotted. REQUIRED. |
attribute_data |
Name of the dataset containing attributes, e.g., points, to be plotted. Dataset must have a pair of columns for geographic coordinates of the attributes (e.g., lat and lon) titled 'x' and 'y'. Coordinate reference system (CRS) for attribute data is automatically transformed to match that of input geographic data. If CRS is missing for attribute data, it is assumed to be WGS84. REQUIRED (for pointmaps and heatmaps only). |
points_col |
Name of the data column containing the label or value to be shown when hovering over a particular point location. For interactive pointmaps only. Default is the first column in the specified attribute dataset. OPTIONAL. |
plot_type |
Name of one of the predefined plot types: current options are 'choropleth', 'pointmap' and 'heatmap'. REQUIRED. |
style |
Name of a defined output style. User defined output styles can be created following examples shown in the help files for tmap (see ?tmap::tmap_options). For illustrative purposes, the current selection of styles are "zissou", "royal", "darjeeling", "bottlerocket", "moonrise" and "isleofdogs" (from the wesanderson R pacakge); 'viridis" and "magma" (from the viridis R package); and "terrain" (from base R). If omitted, defaults to tmap "white" style. OPTIONAL. |
transparency |
value between 0 and 1 (default) that defines transparency of map colours, from transparent (0) to opaque (1). Intermediate values allow more or less visibility of underlying (reference) layers in interactive maps. Applies only to choropleth maps. OPTIONAL. |
levels |
Preferred number of shading categories for choropleth maps when geography_col is a numeric variable. Default is 5. Generates equally sized categories of round numbers, resulting in a number of levels close to, but not necessarily exactly, the specified number of levels. OPTIONAL. |
hover_id |
Name of the data column containing the label or value to be shown when hovering over a particular geographic unit. For interactive choropleth maps only. Default is the name or value given in specified geography_col. OPTIONAL. |
plot_title |
Main title of plot. If omitted, no title is shown. Applies only to static image maps. OPTIONAL. |
legend_title |
Title of plot legend. If no value is given, geography_col name is used. In static maps, the legend is removed if legend_title = 'none'. OPTIONAL. |
scale_bar |
TRUE or FALSE (default). Indicating whether reference scale bar should be shown (bottom left of plot). Applies only to static image maps. OPTIONAL. |
compass |
TRUE or FALSE (default). Indicating whether reference compass should be shown (top right of plot). Applies only to static image maps. OPTIONAL. |
interactive |
TRUE or FALSE (default). Indicating whether map should be generated as an interactive view or as a static image. OPTIONAL. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # simple static choropleth map with plot title and legend title ------------------
geo_plot(data = my_geo_data,
geography_col = 'region_data_column',
plot_type = 'choropleth',
plot_title = 'My Geographic Regions',
legend_title = 'Region Name')
# interactive choropleth map with partial transparency of shaded regions ---------
geo_plot(data = my_geo_data,
geography_col = 'region_data_column',
plot_type = 'choropleth',
transparency = 0.5,
hover_id = 'region_popsize_column',
interactive = TRUE)
# static pointmap with plot title but no legend ----------------------------------
geo_plot(data = my_geo_data,
geography_col = 'region_data_column',
attribute_data = my_point_location_data,
points_col = 'my_point_name_variable',
plot_type = 'pointmap',
plot_title = 'My Point Locations',
legend_title = 'none')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.