--- title: "Extract and Visualize the Population of Mexico (LandScan)" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Extract and Visualize the Population of Mexico (LandScan)} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ```{r setup, warning=FALSE, message=FALSE} library(terra) library(tidyterra) library(popmex) ``` In the official homepage of [LandScan](https://landscan.ornl.gov), is defined as a globally recognized, R&D100-winning population data platform developed at Oak Ridge National Laboratory (ORNL). Its datasets provide human population distribution estimates down to 100 meter grid resolution. LandScan supports disaster response, humanitarian aid, environmental analysis, and urban planning by providing insights into where people live and how they move. ### Load the layers ```{r} lyrs <- popmex::get_landscan() names(lyrs) ``` ### Plot the layer ```{r} pop2026 <- lyrs |> dplyr::select(pop_2026) mapgl::maplibre(palette = viridis::viridis, bounds = sf::st_bbox(rgeomex::AGEM_inegi19_mx)) |> mapgl::add_image_source(id = "pop-2026", data = pop2026) |> mapgl::add_raster_layer(id = "raster", source = "pop-2026") |> # Configuración correcta para datos continuos mapgl::add_legend(legend_title = "Población 2026", values = c(0, 1000, 5000, 10000, 30000, 46919), colors = viridis::viridis(n = 10), type = "continuous", position = "bottom-left") |> mapgl::add_navigation_control() |> mapgl::add_globe_control() |> mapgl::add_scale_control() ```