#' Map heat vulnerability index data to ordinal names
#'
#' 1 represents low exposure, low sensitivity or high adaptive capacity and 5
#' represents high exposure, high sensitivity or low adaptive capacity.
#'
#' @param x list, result from \code{get_heat_vulnerability_index}
#'
#' @export
map_heat_vulnerability_index <- function(x){
attributes_labels <-
c('HVI' = 'Heat vulnerability index',
'Expos_Indx' = "Exposure index",
'Sensi_Indx' = 'Sensitivity index',
'AdapC_Indx' = 'Adaptive capacity')
values = c('low', 'low-moderate', 'moderate', 'moderate-high', 'high')
if (length(x$features) == 0){
message('Address is outside the extent of data. No data is within the features element')
scores = as.list(rep(0, length(attributes_labels)))
names(scores) <- names(attributes_labels)
} else {
scores <- x$features[[1]]$attributes[names(attributes_labels)]
}
out <- vector('list', length(scores))
for(i in seq_along(scores)){
in_var <- names(scores)[i]
in_score <- scores[[i]]
value_text <- ifelse(in_var %in% 'AdapC_Indx',
rev(values)[in_score],
values[in_score])
if (in_score == 0){
value_text = 'no data'
}
out[[i]] <-
list(label = unname(attributes_labels[in_var]),
value = in_score,
value_text = value_text)
}
names(out) <- names(scores)
do.call(dplyr::bind_rows, out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.