Skip to contents

Creates an interactive leaflet map where locations belonging to the same environment group use the same marker color. Ungrouped environments are shown with ungrouped_color.

Usage

map_environment_groups(
  stratification_result,
  locations,
  ignore_case = FALSE,
  group_palette = NULL,
  ungrouped_color = "#7A7A7A",
  match_by = "location",
  strict = TRUE,
  tiles = "breedbase"
)

Arguments

stratification_result

Result from run_environment_stratification() or run_breedbase_environment_stratification().

locations

Location coordinates from read_locations(), a location file path, or a data frame with location, latitude, and longitude columns.

ignore_case

Logical. If TRUE, location matching ignores case.

group_palette

Optional vector of colors used for environment groups.

ungrouped_color

Color for ungrouped environments.

match_by

Name from the stratification result used to match the location column in locations. Use "location" when coordinates are named by location, "environment" when coordinates are named by the constructed environment identifier, or "environment_label" when coordinates are named by display labels.

strict

Logical. If TRUE, stop when any environment location has no matching coordinates.

tiles

Background map. The default, "breedbase", uses the same maps as the 'Breedbase' Locations page: Esri Street (shown first), Topographical and Satellite, with a switch in the top-right corner. They need no account or API key and work in the RStudio viewer and in saved HTML files. "street", "topo" or "satellite" shows only that map. "OpenStreetMap" uses OpenStreetMap's own tiles (these may be refused outside a website). Any other value is passed to leaflet::addProviderTiles() as a provider name; some commercial providers need an API key.

Value

A leaflet htmlwidget.

Examples

pheno_file <- system.file("extdata", "breedbase_pheno.csv", package = "breedtools")
loc_file <- system.file("extdata", "breedbase_locations.csv", package = "breedtools")

result <- run_environment_stratification(pheno_file, trait = "fresh root yield")
locations <- read_locations(loc_file, phenotype_data = result)

group_map <- map_environment_groups(result, locations)
if (interactive()) group_map