Package {mappingAS}


Type: Package
Title: Spatial Metrics and Habitat Conversion for Extinction Risk Assessment
Version: 1.13.2
Author: Antônio Lucas Barreira [aut, cre, cph]
Maintainer: Antônio Lucas Barreira <barreira_rodrigues@hotmail.com>
Description: A spatial analytical framework for preliminary species extinction-risk screening following the IUCN Red List Criterion B guidelines. From occurrence points it computes the Extent of Occurrence (EOO) and Area of Occupancy (AOO) on a data-centred equal-area projection, assigns provisional Criterion B categories, and integrates 'MapBiomas' land-use/land-cover data to quantify the proportion of anthropogenic conversion versus remaining natural habitat within each range metric, with per-class breakdowns and land-cover time series. Several 'MapBiomas' initiatives are supported through one standardised legend - 'MapBiomas' Brazil, the Pan-Amazon / Amazonia collection (RAISG), Colombia, Argentina, Bolivia, Chile, Ecuador, Peru, Venezuela, Paraguay and Uruguay - so a species anywhere these products cover can be screened as readily as a Brazilian one. For ranges outside 'MapBiomas' coverage it can fall back to the global 'Esri' / 'Impact Observatory' 10 m annual land cover derived from 'Sentinel-2' (the product behind the 'ArcGIS' Living Atlas Land Cover Explorer), so a species anywhere on Earth can be screened. It also integrates 'MapBiomas' Fire to compute burned-area metrics and fire time series, and quantifies the overlap of the range with protected areas from the global World Database on Protected Areas (WDPA). 'MapBiomas' data are read either locally over the network via 'GDAL' '/vsicurl/' (no 'Google Earth Engine' account required) or server-side through 'Google Earth Engine' (GEE) for large-scale assessments. Outputs include interactive and publication ready maps and charts, spatial (shapefile/'GeoPackage') and raster exports, and a written assessment report (HTML, text or Word). An interactive 'shiny' application ties the whole workflow together for reproducible conservation planning.
License: MIT + file LICENSE
Encoding: UTF-8
Depends: R (≥ 4.1.0)
Imports: sf (≥ 1.0.0), terra (≥ 1.7.0), shiny, bslib, leaflet, units, lwgeom, readxl, rlang, grid, tools, utils, stats, graphics, grDevices, DT, htmltools, htmlwidgets, ggplot2, plotly, officer
Suggests: rgee, reticulate, writexl, zip, curl, ggnewscale, ggtrendline, ragg, shinyWidgets, testthat (≥ 3.0.0), knitr, rmarkdown, spelling
VignetteBuilder: knitr
Config/testthat/edition: 3
URL: https://github.com/lucasbarreirageo/mappingAS
BugReports: https://github.com/lucasbarreirageo/mappingAS/issues
Config/roxygen2/version: 8.1.0
Language: en-US
NeedsCompilation: no
Packaged: 2026-09-15 17:14:56 UTC; codespace
Repository: CRAN
Date/Publication: 2026-09-26 16:50:08 UTC

mappingAS: Range Metrics and MapBiomas Habitat Conversion

Description

A GeoCat-style toolkit for IUCN Red List Criterion B screening. It imports species occurrence points from XLSX, CSV, or shapefile inputs, computes the Extent of Occurrence (EOO, minimum convex polygon) and the Area of Occupancy (AOO, 2 km grid), and quantifies the percentage of converted (anthropic) versus remaining natural habitat inside both the EOO and the AOO using the most recent MapBiomas land-use/land-cover collection.

Main functions

read_occurrences

Import points from csv/xlsx/shapefile.

assess_species

Full pipeline (EOO, AOO, conversion).

calc_eoo, calc_aoo

Range metrics only.

summarise_conversion

Convert class areas to % converted.

map_species, plot_conversion

Visual output.

run_app

Launch the Shiny GUI.

MapBiomas backends

backend = "local" (default) reads a windowed crop of the national GeoTIFF via GDAL /vsicurl/ (no Google Earth Engine account needed). backend = "gee" uses rgee server-side reductions for very large ranges.

Author(s)

Maintainer: Antônio Lucas Barreira barreira_rodrigues@hotmail.com [copyright holder]

Authors:

See Also

Useful links:


Assess one or many species: EOO, AOO, MapBiomas conversion and fire

Description

End-to-end pipeline. For each species it computes the EOO (minimum convex polygon) and AOO (2 km grid), then quantifies the percentage of converted (anthropic) and remaining natural habitat from the most recent MapBiomas collection inside both the EOO and the AOO. When fire = TRUE it also adds the percentage of the EOO/AOO that has burned and the mean fire recurrence, from the MapBiomas Fire accumulated layer.

Usage

assess_species(
  occ,
  initiative = "brazil",
  year = NULL,
  collection = NULL,
  backend = c("local", "gee"),
  fallback = c("sentinel2", "none"),
  cell_km = 2,
  subpop = TRUE,
  subpop_resol_km = NULL,
  loc_km = 10,
  loc_scale = NULL,
  loc_method = c("no_more_than_one", "other"),
  mapbiomas = TRUE,
  fire = FALSE,
  fire_collection = 4,
  fire_host_collection = 9,
  protected = FALSE,
  pa_src = NULL,
  src = NULL,
  fire_src = NULL,
  water_in_denominator = FALSE,
  area_max_pixels = 5e+07,
  decline = NA,
  extreme_fluctuation = NA,
  severe_fragmentation = NA,
  min_records = 1,
  verbose = TRUE
)

Arguments

occ

An sf of POINT geometries from read_occurrences.

initiative

Land-cover product. A MapBiomas initiative - "brazil" (default), "amazonia" (Pan-Amazon / RAISG), "colombia" or any of the other South-American products (Argentina, Bolivia, Chile, Ecuador, Peru, Venezuela, Paraguay, Uruguay) - selects that product, its default collection and the standardised legend (see mb_initiatives). Two extra keys unlock coverage anywhere on Earth: "sentinel2" forces the global Esri / Impact Observatory 10 m land cover (Sentinel-2, the data behind the ArcGIS Living Atlas Land Cover Explorer; see esri_legend), and "auto" tries MapBiomas first and automatically falls back to Sentinel-2 for ranges outside MapBiomas coverage. All backends stream public Cloud-Optimized GeoTIFFs - no Google Earth Engine and no account.

year

Integer MapBiomas year. NULL (default) uses the most recent year available for the initiative (e.g. 2024 for Brazil/Colombia, 2023 for Amazonia/Paraguay, 2022 for Uruguay).

collection

Integer MapBiomas collection number. NULL (default) uses the initiative default (10/6/3 for Brazil/Amazonia/Colombia).

backend

Habitat backend: "local" (default) or "gee". The "gee" backend is only wired for initiative = "brazil".

fallback

What to do when the chosen MapBiomas product has no data over a species' range (i.e. the occurrences fall outside every supported country): "sentinel2" (default) recomputes that species with the global Sentinel-2 / Esri layer; "none" leaves its conversion as NA. Ignored when initiative = "sentinel2".

cell_km

AOO grid cell size in km (default 2).

subpop

Logical; if TRUE (default) also estimate the number of subpopulations (circular-buffer method) and the number of locations (occupied-grid-cell method). See calc_subpop and calc_locations.

subpop_resol_km

Circular-buffer radius in km for the subpopulation estimate. NULL (default) uses one tenth of the maximum distance between occurrences (Rivers et al. 2010).

loc_km

Grid cell size in km for the number-of-locations estimate (default 10).

loc_scale

Optional sliding-scale cell size for the locations estimate: a fraction of the maximum distance between occurrences (Rivers et al. 2010). When supplied it overrides loc_km. See calc_locations.

loc_method

How protected areas enter the number-of-locations estimate when protected = TRUE: "no_more_than_one" (default; each protected area with occurrences is one location) or "other" (inside and outside protected areas gridded separately). Ignored when protected = FALSE. See calc_locations.

mapbiomas

Logical; if FALSE, only EOO/AOO are computed.

fire

Logical; if TRUE, also compute burned-area metrics from MapBiomas Fire (accumulated layer, read locally). Default FALSE.

fire_collection, fire_host_collection

Fire collection number (default 4) and the initiative folder hosting it (default 9).

protected

Logical; if TRUE, also compute the overlap of the range with protected areas from the global World Database on Protected Areas (WDPA): the share of occurrences inside protected areas and the \ the EOO/AOO within them. Default FALSE. Requires internet unless pa_src is given. See wdpa_areas.

pa_src

Optional local protected-area vector file (.shp/ .gpkg/.geojson) used instead of WDPA (offline).

src

Optional MapBiomas LULC GeoTIFF for the local backend.

fire_src

Optional MapBiomas Fire GeoTIFF (overrides the public URL).

water_in_denominator

Passed to summarise_conversion.

area_max_pixels

Pixel budget for the land-cover area read on the local backend (default 5e7, ~50 million). Ranges whose native window fits the budget are read at full resolution (30 m MapBiomas, 10 m Sentinel-2); larger or widely-spread ranges are read per polygon part and/or decimated with majority resampling so a continental EOO no longer streams billions of pixels. Class proportions - and thus the % converted / natural - are preserved. Raise it for finer reads of huge ranges, lower it for speed. Ignored by the GEE backend (reduction is server-side).

decline, extreme_fluctuation, severe_fragmentation

Expert inputs for the Criterion B sub-criteria, applied by iucn_criterion_B on top of the size thresholds to yield an applicable category (category_B and criterion_B_code in the summary). decline is sub-criterion (b) (a continuing decline), extreme_fluctuation is (c), and severe_fragmentation feeds (a) alongside the estimated number of locations. Each may be a single value applied to every species, or a named logical vector keyed by species name. NA (default) means not documented (treated as not met), so by default a range that only meets a size threshold is reported as NT until a decline or fragmentation is supplied. Sub-criteria (b)/(c) cannot be inferred from occurrence points, hence they are inputs, not computed. DD/NE are never assigned automatically.

min_records

Minimum records required to attempt an assessment.

verbose

Logical; print progress (default TRUE).

Value

An object of class geoconv_assessment: a list with summary (one row per species, including n_subpop and n_locations) and detail (per-species points, eoo, aoo, subpop, locations, eoo_conversion, aoo_conversion, and - when fire = TRUE

Examples

f <- system.file("extdata", "example_occurrences.csv", package = "mappingAS")
occ <- read_occurrences(f)
# EOO/AOO, subpopulations and locations only (offline, no network):
res <- assess_species(occ, mapbiomas = FALSE, verbose = FALSE)
res$summary

# Full screening with MapBiomas land cover and fire (reads data over the web):
res2 <- assess_species(occ, year = 2024, fire = TRUE, verbose = FALSE)
res2$summary


Narrative conservation-assessment report for one species

Description

Builds a written, interpretive summary of a species' preliminary Criterion B screening from an assess_species result. Beyond restating the headline numbers, the text interprets them: the EOO/AOO composition divergence, the effectiveness (not just the extent) of protected-area overlap, and an honest framing of continuing decline (subcriterion b). When the land-cover and/or fire time series are supplied it also analyses their temporal trend. Habitat conversion, fire and protected-area passages appear only when those modules were run. It can be returned as HTML (on-screen preview), plain text, or a Word .docx file (via officer) - the format used by the Shiny app's Report tab.

Usage

assessment_report(
  assessment,
  species = NULL,
  lang = c("en", "pt"),
  output = c("html", "text", "docx"),
  file = NULL,
  cover_series = NULL,
  fire_series = NULL,
  applied_category = NULL,
  applied_code = NULL,
  figures = FALSE
)

Arguments

assessment

A geoconv_assessment from assess_species.

species

Species name (default: the first assessed).

lang

Report language: "en" (default) or "pt".

output

One of "html" (default), "text" or "docx".

file

Target path for output = "docx" (required in that case).

cover_series

Optional land-cover time series for this species (as from timeseries_for_species / cover_timeseries, with year, pct and group columns). When supplied, a temporal trend of habitat conversion is added.

fire_series

Optional burned-area time series (as from fire_timeseries_for_species / fire_timeseries, with year and burned_pct). When supplied, the fire regime is characterised over time.

applied_category, applied_code

Optional applied Criterion B category (e.g. "VU") and full code (e.g. "VU B1ab(iii)") reflecting the user's sub-criteria choices. When supplied, an "Applied Criterion B category" section is added; otherwise the assessment's category_B / criterion_B_code columns are used if present.

figures

Logical; for output = "docx" only, embed the supporting figures (composition, protection and the land-cover/fire time-series charts) in the Word document (default FALSE). Ignored for other outputs.

Value

For "html"/"text", a length-one character string. For "docx", the file path (written as a side effect), invisibly.

Examples

occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                    package = "mappingAS"))
res <- assess_species(occ, mapbiomas = FALSE, verbose = FALSE)
cat(assessment_report(res, output = "text"))

# Word (.docx) report written to a temporary file:
f <- file.path(tempdir(), "report.docx")
assessment_report(res, output = "docx", file = f)
unlink(f)


Area of Occupancy (AOO) via occupied grid cells

Description

Computes the AOO as the number of occupied grid cells multiplied by the cell area, following the IUCN Red List guidelines (reference scale: 2 x 2 km cells = 4 km^2 each) and the approach used by the ConR package. Points are snapped to a regular grid defined on a data-centred equal-area projection.

Usage

calc_aoo(points, cell_km = 2, n_rep = 30)

Arguments

points

An sf of POINT geometries (one species).

cell_km

Grid cell side length in kilometres (default 2).

n_rep

Integer; number of randomly translated grids to test (default 30, matching the typical ConR setting). The minimum occupied-cell count over the replicates is returned.

Details

Because the occupied-cell count depends on where the grid is placed, this function tests several randomly translated grids and returns the smallest count, as ConR does. The returned cells correspond to the grid placement that produced the reported value.

Value

A list with area_km2, n_cells, cell_km, cells (occupied cells as an sfc polygon set in WGS84) and crs_laea.

Examples

f <- system.file("extdata", "example_occurrences.csv", package = "mappingAS")
occ <- read_occurrences(f)
sp1 <- occ[occ$species == occ$species[1], ]
calc_aoo(sp1)$area_km2

Extent of Occurrence (EOO) via minimum convex polygon

Description

Computes the EOO as the area of the convex hull (minimum convex polygon) enclosing all occurrence points, following the IUCN Red List guidelines and the approach used by the ConR package. The hull is built in longitude/latitude, its edges are densified with st_segmentize() so that they follow great circles, and the area is measured directly on the WGS84 ellipsoid (a "spheroid" measurement).

Usage

calc_eoo(points, segmentize_km = 20)

Arguments

points

An sf of POINT geometries (one species). Use read_occurrences to produce it.

segmentize_km

Numeric edge length, in kilometres, used to densify the hull edges along great circles (default 20, matching ConR).

Details

Degenerate cases are handled so the function never errors:

Value

A list with area_km2 (numeric), n_records (integer), n_unique (distinct coordinates), hull (the hull as an sfc in WGS84, or NULL when the EOO is undefined) and crs_laea (a data-centred equal-area proj string, kept for mapping).

Examples

f <- system.file("extdata", "example_occurrences.csv", package = "mappingAS")
occ <- read_occurrences(f)
sp1 <- occ[occ$species == occ$species[1], ]
calc_eoo(sp1)$area_km2

Estimate of number of locations (occupied-grid-cell method, optionally protected-area aware)

Description

Estimates the number of "locations" (in the IUCN sense: geographically or ecologically distinct areas in which a single threatening event can rapidly affect all individuals) by overlaying a regular grid and counting the occupied cells, optionally decoupling occurrences that fall inside protected areas from those outside. This mirrors the two complementary approaches used by the ConR package (Dauby et al. 2017): the grid method, and the protected-area integration (method_protected).

Usage

calc_locations(
  points,
  grid_km = 10,
  n_rep = 30,
  protected = NULL,
  method_protected = c("no_more_than_one", "other"),
  cell_scale = NULL
)

Arguments

points

An sf of POINT geometries (one species).

grid_km

Grid cell side length in kilometres (default 10). Ignored when cell_scale is supplied.

n_rep

Integer; number of randomly translated grids to test (default 30). The minimum occupied-cell count over the replicates is returned.

protected

Optional protected-area layer (an sf/sfc of polygons, e.g. from protected_areas). NULL (default) uses the plain grid method.

method_protected

How protected areas enter the count when protected is given: "no_more_than_one" (default) or "other". See Details.

cell_scale

Optional numeric fraction for the sliding-scale cell size: the cell side becomes cell_scale times the maximum distance between two occurrences. When supplied it overrides grid_km.

Details

As for the AOO, the occupied-cell count depends on where the grid is placed, so several randomly translated grids are tested and the smallest count is returned (the most conservative, i.e. most threatened, estimate). The grid is built on a data-centred Lambert Azimuthal Equal-Area projection and this function reuses mappingAS's own AOO grid machinery, so it differs from calc_aoo only in the (larger) default cell size.

Cell size. By default a fixed cell of grid_km (10 km) is used, representing the scale at which a single threat could affect the whole occupied cell. Alternatively a species-specific "sliding scale" (Rivers et al. 2010) is available: set cell_scale to a fraction (e.g. 0.05) and the cell side becomes that fraction of the maximum distance between two occurrences (cell_scale then overrides grid_km).

Protected areas. When protected is a protected-area layer (e.g. from protected_areas), occurrences are split into those inside and outside protected areas, because a subpopulation inside a protected area is not subject to the same threats as one outside:

With protected = NULL (the default) no protected-area information is used and the plain grid count is returned.

Value

A list with n_locations (integer estimate), grid_km (the cell size actually used), method ("grid", "no_more_than_one" or "other"), n_out / n_in (locations outside / inside protected areas; n_in is NA for the plain grid), n_cells, cells (gridded location cells as an sfc in WGS84), pa_locations (the protected areas counted as locations under "no_more_than_one", else NULL) and crs_laea.

References

Dauby G. et al. (2017) ConR: An R package to assist large-scale multispecies preliminary conservation assessments using distribution data. Ecology and Evolution 7:11292-11303. doi:10.1002/ece3.3704

Rivers M.C. et al. (2010) How many herbarium specimens are needed to detect threatened species? Biological Conservation 143:2545-2560.

IUCN Standards and Petitions Committee. Guidelines for Using the IUCN Red List Categories and Criteria.

See Also

calc_subpop, calc_aoo, protected_areas

Examples

f <- system.file("extdata", "example_occurrences.csv", package = "mappingAS")
occ <- read_occurrences(f)
sp1 <- occ[occ$species == occ$species[1], ]
calc_locations(sp1)$n_locations

Estimate of number of subpopulations (circular-buffer method)

Description

Estimates the number of subpopulations by the "circular buffer" method: a circle of radius resol_km is drawn around every occurrence, the circles are dissolved (unioned), and the number of resulting disjoint polygons is the estimated number of subpopulations. Occurrences whose buffers overlap are treated as belonging to the same subpopulation.

Usage

calc_subpop(points, resol_km = NULL)

Arguments

points

An sf of POINT geometries (one species). Use read_occurrences to produce it.

resol_km

Circle radius in kilometres. NULL (default) uses one tenth of the maximum distance between two occurrences.

Details

This is the approach popularised by the ConR package (Dauby et al. 2017) and originally proposed by Rivers et al. (2010). The buffering is done on a data-centred Lambert Azimuthal Equal-Area projection (see laea_crs), consistent with the EOO/AOO computations elsewhere in mappingAS.

The buffer radius follows the widely used default of one tenth of the greatest distance separating two occurrences (Rivers et al. 2010): when resol_km is NULL it is computed from the data. Because the most distant pair of points always lies on the convex hull, the maximum distance is measured over the hull vertices only (great-circle distance on the WGS84 ellipsoid), which keeps the computation fast for large datasets.

Value

A list with n_subpop (integer estimate), resol_km (the radius actually used), n_unique (distinct coordinates), subpop (the dissolved subpopulation polygons as an sfc in WGS84, or NULL) and crs_laea (the equal-area proj string).

References

Dauby G. et al. (2017) ConR: An R package to assist large-scale multispecies preliminary conservation assessments using distribution data. Ecology and Evolution 7:11292-11303. doi:10.1002/ece3.3704

Rivers M.C. et al. (2010) How many herbarium specimens are needed to detect threatened species? Biological Conservation 143:2545-2560.

See Also

calc_locations, calc_aoo

Examples

f <- system.file("extdata", "example_occurrences.csv", package = "mappingAS")
occ <- read_occurrences(f)
sp1 <- occ[occ$species == occ$species[1], ]
calc_subpop(sp1)$n_subpop

Per-class MapBiomas composition table (every class) for an assessment

Description

Returns, for each species, the area and percentage of every MapBiomas class found inside the EOO and/or the AOO. This complements the headline natural-versus-converted summary in assess_species with the full class-by-class breakdown.

Usage

class_table(assessment, species = NULL, range = c("both", "eoo", "aoo"))

Arguments

assessment

A geoconv_assessment from assess_species (run with mapbiomas = TRUE).

species

Optional species name (or vector). NULL (default) uses all assessed species.

range

"both" (default), "eoo" or "aoo".

Value

A long data.frame with columns species, range ("EOO"/"AOO"), code, class_pt, class_en, group, area_km2 and pct (percentage of the mapped area within that range). Empty (with a warning) if MapBiomas was not computed.

Examples


occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                    package = "mappingAS"))
res <- assess_species(occ, year = 2024, verbose = FALSE)  # reads MapBiomas
class_table(res)


MapBiomas land-cover composition over time for a polygon

Description

For a given area (e.g. an EOO hull or the union of AOO cells), computes the area of each MapBiomas class (or conservation group) for several years, returning a tidy long table suitable for a stacked-area chart of percentage of area versus year (as in the MapBiomas coverage figures).

Usage

cover_timeseries(
  geom,
  years = NULL,
  collection = NULL,
  initiative = "brazil",
  backend = c("local", "gee"),
  src = NULL,
  by = c("class", "group"),
  include_not_observed = FALSE,
  verbose = TRUE,
  max_pixels = 5e+07
)

Arguments

geom

An sf/sfc polygon (any CRS).

years

Integer vector of years. If NULL (default) a 5-year step across the initiative's span (plus the last year) is used.

collection

Integer MapBiomas collection. NULL uses the initiative default.

initiative

One of "brazil" (default), "amazonia" or "colombia" (see mb_initiatives).

backend

"local" (default, windowed GeoTIFF read) or "gee" (Earth Engine; Brazil only).

src

Optional GeoTIFF path/URL for the local backend (overrides the public per-year URL).

by

"class" (default; one series per MapBiomas class, with the official colours) or "group" (natural / anthropic / water / other).

include_not_observed

Logical; keep the "Not Observed" class (default FALSE).

verbose

Logical; print progress (default TRUE).

max_pixels

Pixel budget for each year's local area read (default 5e7). Large or widely-spread ranges are read per polygon part and/or decimated with majority resampling so the read stays bounded; class proportions are preserved. Ignored by the GEE backend.

Details

Each year is read independently (local windowed read or Earth Engine), so a long span of annual data can take a while. By default a 5-year step is used; pass years = mb_years() for the full annual series.

Value

A data.frame (long) with columns year, label, hex, group, area_km2 and pct (percentage of the mapped area in that year). For by = "class" it also has code and class_en.

See Also

plot_timeseries, timeseries_for_species


Sentinel-2 / Esri global 10 m land-cover legend

Description

Returns the 9-class legend of the Esri / Impact Observatory / Microsoft "10 m Annual Land Use Land Cover" product (derived from ESA Sentinel-2, the data behind the ArcGIS Living Atlas Land Cover Explorer), with each pixel class mapped to the same conservation groups used by mappingAS for MapBiomas ("natural", "anthropic", "water", "other", "not_observed"). This lets a range assessed with the global fallback flow through the exact same conversion, plotting and report pipeline as a MapBiomas one (see summarise_conversion).

Usage

esri_legend()

Details

Group mapping: Trees, Rangeland and Flooded Vegetation are natural; Crops and Built Area are anthropic (converted habitat); Water is water; Bare Ground and Snow/Ice are other (ambiguous, excluded from the conversion denominator by default); Clouds are not_observed.

Value

A data.frame with columns code, class_en, class_pt, hex (official Esri colour), level1 and group.

See Also

mb_legend, summarise_conversion

Examples

esri_legend()
subset(esri_legend(), group == "anthropic")$class_en

Export EOO and AOO as spatial files (shapefile or GeoPackage)

Description

Writes the Extent of Occurrence (EOO) polygons and the Area of Occupancy (AOO) polygons produced by assess_species() to disk, with the area, habitat-conversion and provisional-category attributes attached to each feature (one feature per species by default). Handy for opening the results in QGIS/ArcGIS or sharing them.

Usage

export_ranges(
  assessment,
  dir = tempdir(),
  layer_prefix = "mappingAS",
  what = c("both", "eoo", "aoo"),
  format = c("shapefile", "gpkg"),
  crs = 4326,
  aoo_as = c("cells", "union"),
  class_csv = TRUE,
  zip = FALSE,
  quiet = TRUE
)

Arguments

assessment

A geoconv_assessment object from assess_species().

dir

Output directory (created if it does not exist). Default tempdir(); pass an explicit path to keep the files.

layer_prefix

File/layer name prefix. Default "mappingAS".

what

Which ranges to export: "both" (default), "eoo" or "aoo".

format

"shapefile" (default; one file set per range, i.e. ⁠*_EOO.shp⁠ and ⁠*_AOO.shp⁠) or "gpkg" (a single GeoPackage holding both layers).

crs

Output CRS (default 4326, WGS84). Anything accepted by sf::st_crs() also works (an EPSG code or a proj string).

aoo_as

"cells" (default; one feature per occupied 2-km grid cell, each with a cell_id) or "union" (one dissolved feature per species).

class_csv

If TRUE (default), also writes ⁠<prefix>_classes.csv⁠ with the full per-class MapBiomas breakdown (every class) for the EOO and AOO of each species; included in the zip when zip = TRUE. Skipped if MapBiomas was not computed.

zip

If TRUE, the written files are bundled into a single .zip inside dir and the path to that zip is returned (most useful for the shapefile format, which has several sidecar files). Default FALSE.

quiet

Passed to sf::st_write(). Default TRUE.

Details

Because the ESRI Shapefile format limits field names to 10 characters, the attribute fields use compact names (see the Attribute fields section). A GeoPackage (format = "gpkg") stores both ranges as two layers (eoo, aoo) inside a single file and has no such limitation.

Value

(Invisibly) a character vector with the file paths written, or the path to the .zip when zip = TRUE.

Attribute fields

species; eoo_km2 or aoo_km2 (and n_cells for AOO); conv_pct (percent converted/anthropic within that range); nat_pct (percent natural); cat_B1 or cat_B2 (provisional size-only category); prov_cat; mb_year; mb_coll (MapBiomas year and collection). Conversion fields are NA when MapBiomas was not computed.

Examples

occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                    package = "mappingAS"))
res <- assess_species(occ, mapbiomas = FALSE, verbose = FALSE)

d <- file.path(tempdir(), "mappingAS_ranges")
dir.create(d, showWarnings = FALSE)

# Two shapefiles (EOO + AOO) written to a temporary directory:
export_ranges(res, dir = d)

# A single GeoPackage with both layers:
export_ranges(res, dir = d, format = "gpkg")


# Everything bundled into one .zip (good for downloads):
export_ranges(res, dir = d, zip = TRUE)



Standalone HTML species factsheet with user metadata and photos

Description

Builds a single, self-contained HTML file that presents one species as a printable/shareable factsheet - the kind hosted on a supplementary website. It combines two sources of information:

  1. Everything the assessment already computes - range metrics (EOO/AOO and provisional Criterion B category), habitat conversion, fire and protected-area overlap - rendered as a key-metrics grid, the standard charts (composition, protection, and any land-cover / fire time series supplied), a "top anthropic activities" chart derived from the per-class land-cover breakdown, and the interpretive narrative of assessment_report.

  2. Information the package cannot know, supplied by the user: the taxonomy (Family, Genus, Authority), the supporting-information block (Countries, Life Form, Substrate, Habitat, Biome, Vegetation), free-text land use and conservation units, a list of examined vouchers, a taxonomic reference (a Reflora / POWO link, or - for a newly described species - the article citation) and up to four photographs.

The whole page is self-contained (fonts fall back to the system stack, images and charts are embedded as base64 data URIs), so the returned file can be opened offline or published as-is (e.g. on GitHub Pages). Each photograph carries a watermark in its lower-right corner with the owner name given in photo_credit.

Usage

factsheet_html(
  assessment,
  species = NULL,
  lang = c("en", "pt"),
  file = NULL,
  family = NULL,
  genus = NULL,
  authority = NULL,
  countries = NULL,
  life_form = NULL,
  substrate = NULL,
  habitat = NULL,
  biome = NULL,
  vegetation = NULL,
  land_use = NULL,
  conservation_units = NULL,
  vouchers = NULL,
  reference = NULL,
  photos = NULL,
  photo_credit = NULL,
  cover_series = NULL,
  fire_series = NULL,
  applied_category = NULL,
  applied_code = NULL,
  map = TRUE,
  map_interactive = TRUE,
  top_n_threats = 5L
)

Arguments

assessment

A geoconv_assessment from assess_species.

species

Species name (default: the first assessed).

lang

Factsheet language: "en" (default) or "pt".

file

Optional output path. When supplied the HTML is written there and the path is returned invisibly; otherwise the HTML is returned as a length-one character string.

family, genus, authority

Taxonomy fields. genus defaults to the first word of species; the others are user-supplied (optional).

countries, life_form, substrate, habitat, biome, vegetation

The "Supporting information" block, all optional free text.

land_use, conservation_units

Optional overrides. When left NULL they are filled in automatically from the assessment: land_use from the anthropic land-cover classes within the EOO (the Conversion module) and conservation_units from the overlapping protected areas (the Protected-areas module). Pass a string to override the derived value; line breaks are preserved.

vouchers

Optional examined material: a character vector (one voucher per element) or a single string with one voucher per line.

reference

Optional taxonomic reference: a Reflora / POWO URL (rendered as a link) or, for a newly described taxon, the article citation.

photos

Optional character vector of image file paths (PNG/JPEG/...); at most the first four are used.

photo_credit

Watermark text (photo owner). A single value is applied to every photo; a vector is matched per photo.

cover_series, fire_series

Optional land-cover / burned-area time series for this species (as for assessment_report); when supplied they add the temporal-trend narrative and their charts (a land-cover composition-over-time chart, and a burned-area-per-year chart).

applied_category, applied_code

Optional applied Criterion B category (e.g. "VU") and full code (e.g. "VU B1ab(iii)"), reflecting the sub-criteria chosen by the user. When supplied they are shown as an "Applied Criterion B category" metric; otherwise the assessment's category_B / criterion_B_code columns are used if present.

map

Logical; embed the distribution map (occurrence points, EOO, AOO and land cover). Default TRUE; set FALSE to skip it (e.g. offline or for speed).

map_interactive

Logical; when TRUE (default) embed the interactive Leaflet map (map_species, the same widget the app downloads via "Download map (HTML)") as a self-contained document inside an iframe, so the whole factsheet remains one portable file. When FALSE, or when the widget cannot be built (no leaflet / htmlwidgets / pandoc), the publication-ready static map (map_static) is embedded instead.

top_n_threats

Number of anthropic land-cover classes to show in the "top anthropic activities" chart (default 5).

Value

The HTML string, or (when file is given) the file path, invisibly.

See Also

assessment_report for the narrative-only report.

Examples


occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                    package = "mappingAS"))
res <- assess_species(occ, year = 2024, verbose = FALSE)  # reads MapBiomas
out <- file.path(tempdir(), "factsheet.html")
factsheet_html(res, file = out, map = FALSE,
               family = "Gentianaceae", countries = "Brazil",
               life_form = "Herb", biome = "Atlantic Forest")
unlink(out)


Area (km^2) per fire value from a cropped fire raster

Description

Fire analogue of mb_class_areas_raster. For the accumulated product, freq is the fire frequency (years burned).

Usage

fire_areas(r)

Arguments

r

A terra SpatRaster from fire_raster_local.

Value

A data.frame with columns freq and area_km2.


Sequential palette for fire frequency (YlOrRd)

Description

Sequential palette for fire frequency (YlOrRd)

Usage

fire_palette(n = 6)

Arguments

n

Number of breaks (default 6).

Value

A character vector of hex colours.


Crop a MapBiomas Fire raster to an area of interest (local backend)

Description

Thin wrapper over mb_raster_local; reuses its windowed /vsicurl/ read and on-disk cache.

Usage

fire_raster_local(
  aoi,
  year = 2024,
  product = c("accumulated", "annual", "frequency"),
  fire_collection = 4,
  host_collection = 9,
  src = NULL,
  mask = TRUE,
  cache = TRUE,
  cache_dir = NULL
)

Arguments

aoi

An sf/sfc polygon (e.g. an EOO hull or AOO union).

year

Integer year (ignored when product = "accumulated").

product

"accumulated" (default) or "annual".

fire_collection

Fire collection number (default 4).

host_collection

Initiative folder hosting the fire data (default 9; Fire Col.4 lives under collection_9/).

src

Optional GeoTIFF path/URL overriding the built fire URL.

mask, cache, cache_dir

Passed to mb_raster_local.

Value

A terra SpatRaster of fire values clipped to the AOI.


Burned-area time series for a polygon (% of range x year)

Description

Fire analogue of cover_timeseries: reads the annual burned layer for each year and returns burned area (km^2) and percentage of the range. Each year is one windowed read, so a full annual series can be slow.

Usage

fire_timeseries(
  geom,
  years = NULL,
  fire_collection = 4,
  host_collection = 9,
  range_km2 = NULL,
  verbose = TRUE
)

Arguments

geom

An sf/sfc polygon.

years

Integer vector (default mb_years()).

fire_collection

Fire collection number (default 4).

host_collection

Initiative folder hosting the fire data (default 9; Fire Col.4 lives under collection_9/).

range_km2

Range area for the percentage denominator (optional).

verbose

Logical; print progress.

Value

A data.frame with year, burned_km2, burned_pct.


Burned-area time series for one assessed species (EOO or AOO)

Description

Convenience wrapper around fire_timeseries that pulls the stored EOO hull or AOO geometry (and its area) from an assessment.

Usage

fire_timeseries_for_species(
  assessment,
  species = NULL,
  range = c("eoo", "aoo"),
  years = NULL,
  verbose = TRUE
)

Arguments

assessment

A geoconv_assessment from assess_species.

species

Species name (default: first assessed).

range

"eoo" (default) or "aoo".

years, verbose

Passed to fire_timeseries.

Value

The data frame from fire_timeseries with attributes species and range.


Provisional IUCN Red List Criterion B category from range size

Description

Returns the category implied by the EOO (B1) and AOO (B2) size thresholds only. This is a screening aid, exactly like GeoCat: a full Criterion B listing additionally requires at least two of the sub-criteria (a) severe fragmentation / few locations, (b) continuing decline, and (c) extreme fluctuation. Never report these as final categories.

Usage

iucn_category_B(eoo_km2 = NA_real_, aoo_km2 = NA_real_)

Arguments

eoo_km2, aoo_km2

Numeric range sizes in square kilometres.

Value

A list with eoo_category, aoo_category and combined (the more threatened of the two size-based flags).


Apply IUCN Red List Criterion B (size thresholds plus sub-criteria)

Description

Combines the EOO (B1) and AOO (B2) size thresholds of Criterion B with the sub-criteria required for a threatened listing, following the IUCN Red List Categories and Criteria (v3.1) and the Guidelines for Using them (Section 6, Criterion B; Section 10, DD/NT/NE). Unlike iucn_category_B (size flags only), this returns a category that can actually be applied.

Usage

iucn_criterion_B(
  eoo_km2 = NA_real_,
  aoo_km2 = NA_real_,
  n_locations = NA_real_,
  severe_fragmentation = NA,
  decline = NA,
  extreme_fluctuation = NA
)

Arguments

eoo_km2, aoo_km2

EOO and AOO in km^2 (NA if undefined).

n_locations

Estimated number of locations (NA if unknown).

severe_fragmentation

Logical; TRUE if the taxon is severely fragmented. NA (default) = not assessed.

decline

Logical; TRUE if there is a continuing decline (sub-criterion b). NA (default) = not documented.

extreme_fluctuation

Logical; TRUE if there are extreme fluctuations (sub-criterion c). NA (default) = not documented.

Details

A taxon qualifies for a threatened category (CR, EN, VU) only if it meets the size threshold and at least two of these three sub-criteria:

Sub-criterion (a) is derived here from n_locations (and severe_fragmentation when supplied). Sub-criteria (b) and (c) cannot be inferred from occurrence points, so they are expert inputs; left as NA they are treated as not documented (not met).

Following Section 10: a taxon that meets a size threshold but not two sub-criteria is returned as NT (Near Threatened, it "nearly meets" the requirements); one clearly far from every threshold as LC. DD and NE are never assigned automatically - they require the assessor's judgement about data adequacy and are left to the user.

Value

A list with category (one of "CR", "EN", "VU", "NT", "LC", or NA when neither EOO nor AOO is available), code (e.g. "VU B1ab"), qualifies_size (the highest size level met, or NA) and the evaluated sub-criteria a, b, c.

See Also

iucn_category_B

Examples

# EN size, few locations and a documented decline -> EN B1ab
iucn_criterion_B(eoo_km2 = 3000, aoo_km2 = 400, n_locations = 4,
                 decline = TRUE)$code
# Same size but decline not documented -> only one sub-criterion -> NT
iucn_criterion_B(eoo_km2 = 3000, aoo_km2 = 400, n_locations = 4)$category

Build a data-centred equal-area CRS (Lambert Azimuthal Equal Area)

Description

EOO and AOO must be measured on an equal-area projection. This helper returns a LAEA proj string centred on the centroid of geom, which minimises areal distortion for the spatial extent of a single species.

Usage

laea_crs(geom)

Arguments

geom

An sf or sfc object (any CRS; will be treated as WGS84 longitude/latitude for centroid computation).

Value

A character proj4 string suitable for sf::st_transform().


Interactive map of a species' points, EOO and AOO (MapBiomas + fire)

Description

Builds a leaflet map with the occurrence points, EOO hull and occupied AOO cells. Optionally overlays the MapBiomas land-cover raster and the MapBiomas Fire accumulated layer (fire recurrence: number of years burned), both clipped to the EOO, as toggleable layers with legends.

Usage

map_species(
  assessment,
  species = NULL,
  mapbiomas = TRUE,
  fire = FALSE,
  src = NULL,
  fire_src = NULL,
  max_pixels = 800,
  lang = c("pt", "en"),
  clip = c("eoo", "aoo", "all"),
  protected = FALSE,
  pa_src = NULL,
  pa_occ_only = TRUE
)

Arguments

assessment

A geoconv_assessment from assess_species.

species

Species name to plot (default: first assessed).

mapbiomas

Logical; overlay the MapBiomas raster (default TRUE).

fire

Logical; overlay the MapBiomas Fire accumulated layer (default FALSE).

src

Optional MapBiomas LULC GeoTIFF path/URL.

fire_src

Optional MapBiomas Fire GeoTIFF path/URL.

max_pixels

Target maximum raster size (longest side, pixels) for the overlays (default 800).

lang

Legend language: "pt" (default) or "en". Controls the language of the MapBiomas class labels and the fire-frequency legend.

clip

Geometry the rasters are clipped to: "eoo" (default, the EOO hull), "aoo" (the union of occupied AOO cells) or "all" (the union of both, so the raster spans the whole range).

protected

Logical; overlay protected areas. Uses the protected-area layer already stored by assess_species(..., protected = TRUE), or fetches it on the fly from WDPA otherwise. Default FALSE.

pa_src

Optional local protected-area vector file for the overlay (offline).

pa_occ_only

Logical; when TRUE (default) the map draws only the UCs that actually contain occurrences of the species. Set FALSE to draw every UC the range overlaps. Does not affect the EOO/AOO overlap percentages, which are computed over the whole range.

Value

A leaflet widget.


Publication-ready static map of a species (MapBiomas + EOO + AOO + points)

Description

Builds an exportable ggplot2 map for one species: the MapBiomas land-cover layer clipped to the EOO (with the official colour legend of the classes actually present, drawn beside the map so it never overlaps the EOO/AOO), the EOO minimum convex polygon, the occupied AOO cells, the occurrence points, plus a north arrow and a scale bar with the geographic reference (datum/projection) printed beneath it. The map is drawn in the species' equal-area projection so the scale bar is meaningful, and is returned as a ggplot object you can save with ggplot2::ggsave() to make a usable, georeferenced-looking figure.

Usage

map_static(
  assessment,
  species = NULL,
  mapbiomas = TRUE,
  fire = FALSE,
  src = NULL,
  max_pixels = 600,
  crs = NULL,
  scalebar = TRUE,
  north = TRUE,
  title = NULL,
  lang = c("pt", "en"),
  clip = c("eoo", "aoo", "all"),
  protected = FALSE,
  pa_src = NULL,
  pa_occ_only = TRUE
)

Arguments

assessment

A geoconv_assessment from assess_species.

species

Species name (default: first assessed).

mapbiomas

Logical; draw the MapBiomas raster layer (default TRUE). Set FALSE for a quick points/EOO/AOO map with no raster read.

fire

Logical; draw the MapBiomas Fire frequency layer (number of years burned, 1985-2024). With mapbiomas = TRUE it is overlaid on the land-cover raster when ggnewscale is installed; otherwise only the land-cover layer is drawn (default FALSE).

src

Optional local path / URL to a MapBiomas GeoTIFF (same as in assess_species); NULL (default) uses the public URL.

max_pixels

Target maximum raster size (longest side, in pixels) for the display layer (default 600).

crs

Optional CRS for the map (proj string or EPSG code). Defaults to the species' equal-area projection from the EOO/AOO.

scalebar, north

Logical; add a scale bar / north arrow (default TRUE).

title

Optional plot title (default: the species name).

lang

Legend language: "pt" (default) or "en". Controls the language of the MapBiomas class labels, the fire-frequency legend and the feature labels (EOO/AOO/occurrences).

clip

Geometry the rasters are clipped to: "eoo" (default, the EOO hull), "aoo" (the union of occupied AOO cells) or "all" (the union of both). Matches the clip argument of map_species.

protected

Logical; overlay protected areas on the publishable map (default FALSE). Uses the protected-area layer stored by assess_species(..., protected = TRUE), or fetches it on the fly.

pa_src

Optional local protected-area vector file for the overlay (offline).

pa_occ_only

Logical; when TRUE (default) draw only the protected areas that contain occurrences of the species. FALSE draws every protected area the range overlaps.

Details

The MapBiomas layer is read with the cached windowed reader and aggregated to max_pixels for display, so it is fast and reuses the raster already fetched during assess_species (same EOO window).

Value

A ggplot object.

Examples

occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                    package = "mappingAS"))
res <- assess_species(occ, mapbiomas = FALSE, verbose = FALSE)
m <- map_static(res, mapbiomas = FALSE)

# Save it wherever you like (a temporary file here):
f <- file.path(tempdir(), "eoo_map.png")
ggplot2::ggsave(f, m, width = 8, height = 7)
unlink(f)


Turn a mappingAS chart into an interactive plotly widget

Description

Converts a ggplot2 object produced by the mappingAS plot_* functions (plot_conversion, plot_protection, plot_timeseries, plot_fire_timeseries) into an interactive plotly widget. Those functions attach the tidy data and palette needed, so the widget is built as native plotly (correct per-segment hover tooltips and in-bar labels) rather than through ggplotly(). Any other ggplot falls back to ggplotly(). This is the single place that controls the interactive look across the package and the Shiny app.

Usage

mas_plotly(p, tooltip = c("fill", "x", "y"), ...)

Arguments

p

A ggplot object (as returned by the plot_* functions). Any non-ggplot is returned unchanged.

tooltip

Aesthetics passed to plotly::ggplotly() in the generic fallback (default c("fill", "x", "y")).

...

Reserved for future use.

Value

A plotly htmlwidget (or p unchanged when it is not a ggplot or plotly is not installed).

Examples

if (interactive()) {
  occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                      package = "mappingAS"))
  res <- assess_species(occ, year = 2024, verbose = FALSE)  # reads MapBiomas
  mas_plotly(plot_conversion(res))
}

MapBiomas class areas via Google Earth Engine (optional backend)

Description

Computes the area (km^2) of each MapBiomas pixel class inside aoi entirely on Google Earth Engine, without downloading any raster. This is the recommended backend for very large ranges (e.g. continental EOOs) where a local windowed read would transfer too much data.

Usage

mb_class_areas_gee(
  aoi,
  year = 2024,
  collection = 10,
  version = "v1",
  asset = "projects/mapbiomas-public/assets/brazil/lulc/v1",
  scale = 30,
  max_pixels = 1e+13
)

Arguments

aoi

An sf/sfc polygon (any CRS).

year

Integer year (default 2024).

collection

Integer MapBiomas collection id (default 10).

version

Asset version string for the public LULC collection (default "v1"; some mirrors expose "v2" for Collection 10.1).

asset

Earth Engine ImageCollection id (default "projects/mapbiomas-public/assets/brazil/lulc/v1").

scale

Nominal pixel scale in metres for the reduction (default 30).

max_pixels

Maximum pixels for the server-side reduction (default 1e13).

Details

Requires the rgee package and an initialised Earth Engine session (rgee::ee_Initialize()); see the package README for one-time setup.

Value

A data.frame with columns code and area_km2.


Tabulate area per MapBiomas class from a cropped raster

Description

Computes the true (geodesic, latitude-corrected) area of each MapBiomas pixel class inside a cropped/masked raster. Works for rasters in geographic CRS, where pixel area varies with latitude, by using terra::cellSize().

Usage

mb_class_areas_raster(r)

Arguments

r

A terra SpatRaster of MapBiomas codes (e.g. from mb_raster_local).

Value

A data.frame with columns code and area_km2.


Build a MapBiomas Fire (Fogo) GeoTIFF URL

Description

"frequency" is the fire-frequency layer (pixel = number of years burned over period, 1-40); "accumulated" is binary (burned at least once); "annual" is the per-year burned area.

Usage

mb_fire_url(
  year = 2024,
  product = c("accumulated", "annual", "frequency"),
  fire_collection = 4,
  host_collection = 9,
  period = c(1985, 2024)
)

Arguments

year

Integer year (ignored when product = "accumulated").

product

"accumulated" (default) or "annual".

fire_collection

Fire collection number (default 4).

host_collection

Initiative folder hosting the fire data (default 9; Fire Col.4 lives under collection_9/).

period

Two-integer accumulated span (default c(1985, 2024)).

Value

A length-1 character URL.

Examples

mb_fire_url(product = "accumulated")
mb_fire_url(2024, "annual")

Group lookup vectors for MapBiomas conservation groups

Description

Convenience wrapper returning the pixel codes that belong to each group.

Usage

mb_groups(collection = 10, initiative = "brazil")

Arguments

collection

Integer collection number. Interpreted together with initiative; a value that does not match the initiative's default collection emits a warning and the standardised legend is still returned.

initiative

One of the keys of mb_initiatives ("brazil" by default). Kept for API symmetry and warning logic; the returned legend is the same standardised table for every initiative.

Value

A named list with elements natural, anthropic, water, other and not_observed, each an integer vector of MapBiomas pixel codes.


MapBiomas initiatives supported by mappingAS

Description

mappingAS can read land-use/land-cover from several public MapBiomas initiatives, all streamed as annual Cloud-Optimized GeoTIFFs from the public storage.googleapis.com/mapbiomas-public bucket via GDAL's /vsicurl/ driver - no Google Earth Engine account and no Google Drive download required. Each initiative is one coherent product with its own default collection, year span and file layout, but all share the same standardised legend (see mb_legend), so a species whose range spans more than one product can be assessed with consistent class names, colours and conservation groups.

Usage

mb_initiatives()

Details

"brazil"

MapBiomas Brazil, Collection 10 (1985-2024).

"amazonia"

MapBiomas Amazonia / Pan-Amazon (RAISG), Collection 6 (1986-2023). The whole Amazon basin across countries.

"colombia"

MapBiomas Colombia, Collection 3 (1985-2024).

"argentina"

MapBiomas Argentina, Collection 2 (1985-2024).

"bolivia"

MapBiomas Bolivia, Collection 3 (1985-2024).

"chile"

MapBiomas Chile, Collection 1 (2000-2022).

"ecuador"

MapBiomas Ecuador, Collection 3 (1985-2024).

"peru"

MapBiomas Peru, Collection 3 (1985-2024).

"venezuela"

MapBiomas Venezuela, Collection 2 (1985-2023).

"paraguay"

MapBiomas Paraguay, Collection 2 (1985-2023).

"uruguay"

MapBiomas Uruguay, Collection 1 (1985-2022).

Value

A named list, one element per initiative, each a list with label (human-readable name), collection (default collection number), years (integer vector of available years) and key.

See Also

mb_source_url, mb_legend, assess_species

Examples

names(mb_initiatives())
mb_initiatives()$peru$years

Standardised MapBiomas legend with conservation groupings

Description

Returns the standardised MapBiomas land-use/land-cover legend used across every initiative supported by mappingAS (Brazil, Pan-Amazon / Amazonia, Colombia, Argentina, Bolivia, Chile, Ecuador, Peru, Venezuela, Paraguay and Uruguay - see mb_initiatives), with each pixel class assigned to a conservation-relevant group: "natural", "anthropic", "water", "not_observed" or "other". The "anthropic" classes are what counts as converted habitat; "natural" is the remaining (current) natural habitat. By default "water", "not_observed" and "other" are excluded from the conversion denominator (see summarise_conversion).

Usage

mb_legend(collection = 10, initiative = "brazil")

Arguments

collection

Integer collection number. Interpreted together with initiative; a value that does not match the initiative's default collection emits a warning and the standardised legend is still returned.

initiative

One of the keys of mb_initiatives ("brazil" by default). Kept for API symmetry and warning logic; the returned legend is the same standardised table for every initiative.

Details

MapBiomas harmonises pixel codes across its initiatives, so a single legend can label every country's raster consistently - this is what makes cross-border assessment possible for a species whose range spans more than one product. The table is the union of the classes that occur in any of the products; a code that does not occur in a given raster simply contributes zero area. Besides the Brazil Collection 10 classes it includes the classes specific to the other countries - e.g. Andinean formations (81, 82), Glacier (34), primary/secondary/dwarf forest (59, 60, 67), scrubland/steppe/fog oasis/peatlands (66, 63, 70, 73), Pinus/Eucalyptus plantations (79, 80) and salt flat (61).

Value

A data.frame with columns code, class_en, class_pt, hex (standardised MapBiomas colour), level1 and group.

Examples

head(mb_legend())
subset(mb_legend(), group == "anthropic")$class_en

Official MapBiomas colours for a set of class codes

Description

Official MapBiomas colours for a set of class codes

Usage

mb_palette(
  codes = NULL,
  collection = 10,
  initiative = "brazil",
  by = c("code", "class_pt", "class_en")
)

Arguments

codes

Optional integer vector of MapBiomas pixel codes. If NULL (default) colours for the full legend are returned.

collection

Integer collection number. Interpreted together with initiative; a value that does not match the initiative's default collection emits a warning and the standardised legend is still returned.

initiative

One of the keys of mb_initiatives ("brazil" by default). Kept for API symmetry and warning logic; the returned legend is the same standardised table for every initiative.

by

One of "code" (names are codes) or "class_pt" / "class_en" (names are class labels). Default "code".

Value

A named character vector of hex colours.

Examples

mb_palette(c(3, 15, 39, 33))

Crop a MapBiomas LULC raster to an area of interest (local backend)

Description

Reads the MapBiomas national mosaic and crops/masks it to aoi using terra. By default it streams a windowed read of only the AOI's bounding box from the public GeoTIFF via GDAL's /vsicurl/ driver, so there is no Google Earth Engine account and no full-country download. For offline or repeated use, point src to a local GeoTIFF instead.

Usage

mb_raster_local(
  aoi,
  year = 2024,
  collection = NULL,
  initiative = "brazil",
  src = NULL,
  mask = TRUE,
  cache = TRUE,
  cache_dir = NULL
)

Arguments

aoi

An sf/sfc polygon (any CRS) defining the area to extract, e.g. an EOO hull or the union of AOO cells.

year

Integer year (default 2024).

collection

Integer collection number. NULL uses the initiative default (10/6/3 for Brazil/Amazonia/Colombia).

initiative

One of "brazil" (default), "amazonia" or "colombia" (see mb_initiatives).

src

Optional path or URL to a MapBiomas GeoTIFF. If NULL (default) the public URL for year/collection/initiative is used through /vsicurl/.

mask

Logical; if TRUE (default) pixels outside the polygon are set to NA. If FALSE only a rectangular crop is returned.

cache

Logical; if TRUE (default) the rectangular windowed crop is cached on disk (keyed by source + bounding box), so reading the same area again (e.g. the EOO during assessment and later when mapping, or a re-run) does not re-download. Masking is always applied in memory after the cached crop is loaded.

cache_dir

Directory for the windowed-crop cache (default a mappingAS_mb_cache folder under tempdir()).

Details

For very large ranges (e.g. continental EOOs) the windowed read can still transfer a lot of data; in that case prefer mb_class_areas_gee.

Value

A terra SpatRaster of MapBiomas pixel codes restricted to the AOI, in the raster's native CRS.


Build the MapBiomas land-use GeoTIFF URL for a given year and initiative

Description

Returns the public Google Cloud Storage URL of the MapBiomas land-use/land-cover annual mosaic for the chosen initiative. All supported initiatives publish annual single-year Cloud-Optimized GeoTIFFs on the same public bucket, so they can be streamed with GDAL's /vsicurl/ driver (no Google Earth Engine, no Google Drive). See mb_initiatives for the full list of initiatives, their default collections and year spans.

Usage

mb_source_url(year = 2024, collection = NULL, initiative = "brazil")

Arguments

year

Integer year.

collection

Integer collection number. NULL (default) uses the initiative's default collection.

initiative

One of the keys of mb_initiatives ("brazil" by default).

Value

A length-1 character URL.

Examples

mb_source_url(2024)
mb_source_url(2023, initiative = "amazonia")
mb_source_url(2024, initiative = "peru")

Years available for a MapBiomas initiative/collection

Description

Years available for a MapBiomas initiative/collection

Usage

mb_years(collection = 10, initiative = "brazil")

Arguments

collection

Integer collection number. Interpreted together with initiative; a value that does not match the initiative's default collection emits a warning and the standardised legend is still returned.

initiative

One of the keys of mb_initiatives ("brazil" by default). Kept for API symmetry and warning logic; the returned legend is the same standardised table for every initiative.

Value

An integer vector of years available for the initiative (e.g. Brazil 1985-2024, Amazonia 1986-2023, Paraguay 1985-2023, Uruguay 1985-2022).

Examples

range(mb_years())
range(mb_years(initiative = "amazonia"))

Per-species table of Protected areas overlapping the range

Description

Long data.frame (one row per species x UC) listing each federal UC that contains occurrences of, or overlaps the EOO of, each assessed species. Requires assess_species(..., protected = TRUE).

Usage

pa_table(assessment, species = NULL)

Arguments

assessment

A geoconv_assessment from assess_species().

species

Optional species name(s); NULL (default) uses all.

Value

A data.frame with species, pa_name, pa_category, pa_group, n_occ (occurrences of that species inside the UC) and overlap_eoo_km2.


Regression trendline of one land-cover class through time

Description

Fits a regression of a single land-cover class (or conservation group) percentage of area against year and plots the observed points with the fitted curve, its equation, R-squared and p-value. When the ggtrendline package is installed (https://CRAN.R-project.org/package=ggtrendline) it is used to draw the trendline and annotate the statistics; otherwise the function falls back to a plain ggplot2 linear fit carrying the same statistics, and finally to base graphics.

Usage

plot_class_trendline(
  ts,
  class_label = NULL,
  model = "line2P",
  title = NULL,
  lang = c("en", "pt")
)

Arguments

ts

A long data frame from cover_timeseries or timeseries_for_species.

class_label

The label (class or group name) to analyse. When NULL (default), the class with the largest mean percentage across the series is used.

model

ggtrendline model, one of "line2P" (linear, default), "line3P" (quadratic), "log2P", "exp2P", "exp3P", "power2P" or "power3P". Ignored (a linear fit is used) when ggtrendline is not installed.

title

Optional plot title. When NULL, a title is built from the class name and the species/range attributes when present.

lang

Axis/title language: "en" (default) or "pt". When "en" the English MapBiomas class names (class_en) are used when available.

Value

A ggplot object when ggplot2 is available; otherwise NULL (invisibly) after drawing a base plot.

See Also

plot_timeseries, timeseries_for_species


Habitat composition chart (natural / altered / water / other) for EOO and AOO

Description

Draws, for one species, two horizontal stacked bars (EOO and AOO) showing the MapBiomas composition as a percentage of the mapped (observed) area: natural, altered (anthropic), water and other. Segment labels are placed inside each bar and the legend sits below the plot, so nothing overlaps. The headline terrestrial converted percentage is shown as a subtitle.

Usage

plot_conversion(assessment, species = NULL, lang = c("en", "pt"))

Arguments

assessment

A geoconv_assessment.

species

Species name (default: first).

lang

Label language: "en" (default) or "pt".

Details

When ggplot2 is available (a hard dependency) the function returns a ggplot object, which mas_plotly can turn into an interactive chart; otherwise it draws a base-graphics fallback and returns the percentage matrix invisibly.

Value

A ggplot object (ggplot2 available) or, in the base-graphics fallback, invisibly the plotted percentage matrix.

See Also

mas_plotly for the interactive version.


MapBiomas composition donut charts (EOO and AOO)

Description

Two side-by-side donut (ring) charts summarising the MapBiomas composition of the Extent of Occurrence (EOO) and Area of Occupancy (AOO) of a species, in the official MapBiomas colours. Slices can be individual land-cover classes (by = "class") or the four conservation groups (by = "group"). Designed to be exported as a transparent-background PNG (all panel/plot/legend backgrounds are transparent), and the interactive plotly version (via mas_plotly) adds outside labels with leader lines and a transparent export.

Usage

plot_conversion_donut(
  assessment,
  species = NULL,
  by = c("class", "group"),
  lang = c("en", "pt")
)

Arguments

assessment

A geoconv_assessment from assess_species (run with mapbiomas = TRUE).

species

Optional species name. NULL (default) uses the first assessed species.

by

"class" (default) for one ring slice per MapBiomas class, or "group" for the Natural / Altered / Water / Other summary.

lang

"en" (default) or "pt" for slice labels.

Value

A ggplot object (with mappingAS metadata attached in attribute "mas" so mas_plotly can build the interactive donut). Stops with an informative message if no class data are available.

Examples


occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                    package = "mappingAS"))
res <- assess_species(occ, year = 2024, verbose = FALSE)  # reads MapBiomas
plot_conversion_donut(res, by = "class")


Bar/line chart of burned area (%) over time

Description

Bar/line chart of burned area (%) over time

Usage

plot_fire_timeseries(ts, title = NULL, lang = c("en", "pt"))

Arguments

ts

A data frame from fire_timeseries / fire_timeseries_for_species.

title

Optional title (built from attributes when NULL).

lang

Label language: "en" (default) or "pt".

Value

A ggplot object when ggplot2 is available; otherwise NULL after a base plot.


Protection chart (inside vs outside Protected areas) for EOO and AOO

Description

Two horizontal stacked bars (EOO and AOO) showing the share of the range inside federal Protected areas (Protected areas, UCs) versus outside, from assess_species(..., protected = TRUE). When MapBiomas was also computed (mapbiomas = TRUE), the inside-UC part is split into natural and altered habitat, so the dark-green segment is the range that is natural and protected. Layout mirrors plot_conversion: title, one subtitle with the occurrence count, and a legend on the right.

Usage

plot_protection(assessment, species = NULL, lang = c("en", "pt"))

Arguments

assessment

A geoconv_assessment run with protected = TRUE.

species

Species name (default: first).

lang

Label language: "en" (default) or "pt".

Value

A ggplot object (ggplot2 available) or, in the base-graphics fallback, invisibly the plotted percentage matrix (rows EOO/AOO).

See Also

mas_plotly for the interactive version.

Examples


occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                    package = "mappingAS"))
res <- assess_species(occ, protected = TRUE, verbose = FALSE)  # reads WDPA
plot_protection(res)


Stacked-area chart of land-cover percentage over time

Description

Draws percentage of area versus year as stacked areas, one band per class (or group), using the official MapBiomas colours, in the style of the MapBiomas coverage figures. Uses ggplot2 when available, otherwise base graphics.

Usage

plot_timeseries(ts, title = NULL, legend = TRUE, lang = c("en", "pt"))

Arguments

ts

A long data frame from cover_timeseries or timeseries_for_species.

title

Optional plot title. If NULL, a title is built from the species/range attributes when present.

legend

Logical; draw the class legend (default TRUE).

lang

Legend language: "en" (default) or "pt". When "en", the band labels use the MapBiomas class_en column (when present in ts) and the axis/legend/title text is in English.

Value

A ggplot object (invisibly) when ggplot2 is available; otherwise NULL after drawing a base plot.


Read Protected areas intersecting an area of interest

Description

Returns the protected-area polygons that fall within the bounding box of aoi. By default it reads the global World Database on Protected Areas (WDPA) via wdpa_areas() (see there for the source), so the overlap works anywhere in the world. For offline use, point src to a local protected-area file (.shp, .gpkg, .geojson) instead; it is then filtered to the AOI bounding box and standardised to the same columns.

Usage

protected_areas(aoi, src = NULL, cache = TRUE, cache_dir = NULL, quiet = TRUE)

Arguments

aoi

An sf/sfc polygon or point set (any CRS) defining the area of interest, e.g. an EOO hull, the union of AOO cells, or the occurrence points.

src

Optional path/URL to a local protected-area vector file. When supplied WDPA is not queried and the file is filtered to the AOI bounding box.

cache, cache_dir

Cache the WDPA result on disk (default TRUE; folder mappingAS_pa_cache under tempdir()).

quiet

Passed to sf::st_read() (default TRUE).

Details

The result carries three standardised columns: pa_name, pa_category and pa_group, plus all original attributes.

Value

An sf of protected-area polygons in EPSG:4326 (possibly with zero rows when none intersects the AOI), or NULL if the source could not be read.

See Also

wdpa_areas()

Examples


occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                    package = "mappingAS"))
sp1 <- occ[occ$species == occ$species[1], ]
pas <- protected_areas(calc_eoo(sp1)$hull)  # reads WDPA over the web
unique(pas$pa_name)


Read species occurrence points from XLSX, CSV or vector files

Description

Imports occurrence records from a spreadsheet (.xlsx/.xls), delimited text (.csv/.tsv/.txt) or a vector file (.shp, .gpkg, .geojson; for shapefiles you may also pass a .zip containing the .shp/.shx/.dbf/.prj set) and returns a clean point sf in WGS84 (EPSG:4326) with a standardised species column.

Usage

read_occurrences(
  path,
  species_col = NULL,
  lon_col = NULL,
  lat_col = NULL,
  crs = 4326,
  sheet = NULL,
  sep = NULL,
  dec = NULL,
  encoding = "UTF-8",
  default_species = "sp1"
)

Arguments

path

Path to the input file.

species_col, lon_col, lat_col

Optional column names to override auto-detection. lon_col/lat_col are ignored for vector files that already carry geometry.

crs

Input CRS for tabular coordinates (default 4326). Output is always reprojected to WGS84.

sheet

For Excel inputs, the sheet name or index (default first sheet).

sep

For delimited text, the field separator. If NULL (default) it is auto-detected from the header line (;, , or tab).

dec

Decimal mark for delimited text. If NULL (default) it is inferred from sep (, when sep is ;, else .), matching Brazilian Excel exports.

encoding

File encoding for delimited text (default "UTF-8"; use e.g. "latin1" for Windows-1252 files).

default_species

Species label used when no species column is found (default "sp1").

Details

Longitude, latitude and species columns are auto-detected from common header names (Darwin Core decimalLongitude/decimalLatitude, lon/lat, x/y, scientificName, etc.). You can override the detection with the corresponding arguments. Rows with missing or out-of-range coordinates are dropped with a message.

For delimited text the field separator and decimal mark are auto-detected, so Brazilian-style CSVs exported from Excel (; separator, , decimals, optional UTF-8 BOM) are read correctly without extra arguments.

Value

An sf of POINT geometries in EPSG:4326 with a species column plus all original attributes.

Examples

f <- system.file("extdata", "example_occurrences.csv", package = "mappingAS")
occ <- read_occurrences(f)
table(occ$species)

Launch the mappingAS Shiny application

Description

Starts the interactive app for uploading occurrences, computing EOO/AOO and MapBiomas habitat conversion, and exploring/exporting the results.

Usage

run_app(launch.browser = TRUE, max_upload_mb = 500, ...)

Arguments

launch.browser

Logical; open in the default browser (default TRUE).

max_upload_mb

Maximum size, in megabytes, of a file that can be uploaded in the app (default 500). Shiny's own default is only 5 MB, which rejects large occurrence tables before they can be read; raise this for very large datasets. Set to NULL to leave any pre-existing shiny.maxRequestSize option untouched.

...

Passed to shiny::runApp().

Value

Invisibly NULL; called for its side effect.

Examples

if (interactive()) {
  run_app()
  # allow uploads up to 2 GB
  run_app(max_upload_mb = 2048)
}

Crop a Sentinel-2 / Esri LULC mosaic to an area of interest

Description

Global analogue of mb_raster_local for the Esri / Impact Observatory 10 m Annual Land Use Land Cover product. Determines the MGRS grid-zone tile(s) intersecting aoi, streams a windowed read of each via GDAL's /vsicurl/ driver (no Google Earth Engine, no account), masks to the polygon and, when the AOI spans more than one tile, merges the pieces (reprojected to geographic coordinates for display). For accurate area statistics the assessment path tabulates each tile in its native projection and sums, rather than reprojecting; use summarise_conversion on the class areas for that.

Usage

s2_raster_local(
  aoi,
  year = 2023,
  src = NULL,
  base_url = NULL,
  mask = TRUE,
  cache = TRUE,
  cache_dir = NULL
)

Arguments

aoi

An sf/sfc polygon (any CRS), e.g. an EOO hull or the union of AOO cells.

year

Integer year (2017-2023, default 2023).

src

Optional path/URL to a single Esri LULC GeoTIFF (ends in .tif, used as-is), or a base-URL prefix that replaces the default bucket. If NULL (default) the public bucket is used through /vsicurl/.

base_url

Base URL of the public bucket (see s2_source_url).

mask

Logical; if TRUE (default) pixels outside the polygon are set to NA.

cache

Logical; cache the windowed crops on disk (default TRUE).

cache_dir

Directory for the crop cache (default under tempdir()).

Value

A terra SpatRaster of Esri land-cover codes for the AOI.

See Also

esri_legend, s2_source_url, mb_raster_local


Build the Sentinel-2 / Esri land-cover GeoTIFF URL for a tile and year

Description

Returns the public Cloud-Optimized GeoTIFF URL of one MGRS grid-zone tile of the Esri / Impact Observatory 10 m Annual Land Use Land Cover product. The global mosaic is tiled by MGRS grid-zone designator (e.g. "47P"); an area of interest usually intersects one or a few tiles, which the local backend resolves automatically (see s2_raster_local).

Usage

s2_source_url(tile, year = 2023, base_url = NULL)

Arguments

tile

MGRS grid-zone designator (UTM zone number + latitude band letter), e.g. "47P". The public bucket zero-pads the zone to two digits (e.g. "01C").

year

Integer year (2017-2023).

base_url

Base URL of the public bucket holding the per-tile COGs. Defaults to the public AWS Open Data bucket io-10m-annual-lulc; kept overridable so a mirror or an updated layout can be used without changing the package.

Value

A length-1 character URL of the form <base>/<tile>_<year>.tif.

See Also

s2_raster_local, esri_legend

Examples

s2_source_url("47P", 2023)

Years available for the global Sentinel-2 / Esri land-cover series

Description

Years available for the global Sentinel-2 / Esri land-cover series

Usage

s2_years()

Value

An integer vector of the years covered by the Esri / Impact Observatory 10 m Annual Land Use Land Cover product (currently 2017-2023).

See Also

esri_legend, s2_source_url, assess_species

Examples

range(s2_years())

Summarise habitat conversion from MapBiomas class areas

Description

Aggregates a table of per-class areas into conservation groups and computes the percentage of converted (anthropic) versus remaining natural habitat.

Usage

summarise_conversion(
  class_areas,
  collection = 10,
  initiative = "brazil",
  water_in_denominator = FALSE
)

Arguments

class_areas

Either a data.frame with columns code and area_km2 (e.g. from mb_class_areas_gee) or a terra SpatRaster of MapBiomas codes (which is tabulated via mb_class_areas_raster).

collection

Integer collection number (default 10).

initiative

One of "brazil" (default), "amazonia" or "colombia"; selects the standardised legend context (see mb_legend).

water_in_denominator

Logical; if TRUE, water is treated as natural and included in the terrestrial denominator (default FALSE).

Details

The headline metrics use a terrestrial denominator (natural + anthropic), excluding water, not-observed and ambiguous "other" classes, which is the most defensible measure of habitat conversion. A total-area version (denominator = everything except not-observed) is also returned for transparency.

Value

A list with: converted_pct, natural_pct (terrestrial, the headline numbers), converted_pct_total, natural_pct_total, the group areas (natural_km2, anthropic_km2, water_km2, other_km2, not_observed_km2, total_km2) and by_class (the per-class table joined to the legend).

Examples

ca <- data.frame(code = c(3, 15, 24, 33), area_km2 = c(60, 30, 10, 5))
summarise_conversion(ca)$converted_pct

Summarise fire pressure inside a range

Description

Fire analogue of summarise_conversion. Pass the known range area (range_km2, e.g. eoo$area_km2) as denominator so the percentage is exact and robust to the raster's NoData handling.

Usage

summarise_fire(fire_areas, range_km2 = NULL)

Arguments

fire_areas

A data.frame from fire_areas.

range_km2

Total range area (km^2). If NULL, the sum of all tabulated cells is used (valid only when unburned pixels are coded 0).

Value

A list with burned_km2, total_km2, burned_pct, freq_mean, freq_max and by_freq.


Overlap between a species' range and federal Protected areas

Description

Given a species' occurrence points and (optionally) its EOO and AOO, plus a UC layer from protected_areas(), computes how much of the range is legally protected: the share of occurrences inside UCs, the percentage/area of the EOO and AOO that fall within UCs, and the list of UCs touched.

Usage

summarise_protected(points, pa, eoo = NULL, aoo = NULL)

Arguments

points

An sf of POINT geometries (one species).

pa

A UC sf from protected_areas() (standardised columns).

eoo, aoo

The eoo/aoo sublists produced by assess_species() (or calc_eoo()/calc_aoo()). Either may be NULL.

Details

Percentages are computed on the species' equal-area projection so ratios are exact; the reported eoo_km2/aoo_km2 inside UCs are derived from the headline EOO/AOO so they stay consistent with assess_species(). The AOO overlap follows the grid nature of the metric: an occupied 2-km cell counts as protected when it intersects any UC.

Value

A list: n_occ, n_occ_in, occ_pct; eoo_pct, eoo_km2; aoo_pct, aoo_km2, aoo_cells_in; n_uc; list (per-UC data.frame) and layer (the UC sf).


Land-cover time series for one assessed species (EOO or AOO)

Description

Convenience wrapper that pulls the stored EOO hull or AOO geometry from an assessment and runs cover_timeseries on it, reusing the assessment's collection and backend by default.

Usage

timeseries_for_species(
  assessment,
  species = NULL,
  range = c("eoo", "aoo"),
  years = NULL,
  by = c("class", "group"),
  src = NULL,
  verbose = TRUE,
  max_pixels = 8e+06
)

Arguments

assessment

A geoconv_assessment from assess_species.

species

Species name (default: first assessed species).

range

"eoo" (default) or "aoo".

years, by, src, verbose

Passed to cover_timeseries.

max_pixels

Pixel budget per year, passed to cover_timeseries. Defaults to 8e6 (~8 million) - much lower than the single-snapshot assessment, because a composition trend is a ratio and needs far less resolution, and every year is a separate read: the coarser budget makes a multi-year series over a large range several times faster with no meaningful change to the percentages.

Value

The long data frame from cover_timeseries, with attributes species and range set.


Build examined-voucher strings from occurrence attributes

Description

Derives a character vector of herbarium-style voucher citations from the attribute columns of an occurrence table (or the sf returned by read_occurrences), so the "Examined vouchers" box of the factsheet can be filled automatically instead of by hand.

Usage

vouchers_from_occ(
  occ,
  species = NULL,
  voucher_col = NULL,
  collector_col = NULL,
  number_col = NULL,
  herbarium_col = NULL,
  unique = TRUE,
  sort = TRUE
)

Arguments

occ

A data frame or an sf of occurrence records. Geometry, if present, is ignored.

species

Optional species name (or vector) to filter the rows before building the vouchers, matched against the species column when it exists. NULL (default) uses every row.

voucher_col, collector_col, number_col, herbarium_col

Optional column names overriding the automatic detection. Set a column to NA to disable that part of the detection.

unique

Collapse duplicate vouchers to a single entry (default TRUE).

sort

Sort the returned vouchers alphabetically (default TRUE).

Details

Two strategies are tried, in order:

  1. If a ready-made voucher column exists (e.g. voucher, exsiccata, material) its non-empty values are used verbatim.

  2. Otherwise a collector column (e.g. collector, recordedBy) is combined with a collection-number column (e.g. collectorNumber, recordNumber) into "Collector Number". When a herbarium/institution column is present (e.g. herbarium, institutionCode) its code is appended in parentheses, giving "Collector Number (RB)".

Column names are matched case-insensitively from a set of common Darwin Core and herbarium aliases; pass the *_col arguments to override the detection. When no relevant column is found, an empty character vector is returned (so the caller simply leaves the box empty).

Value

A character vector of voucher strings (possibly empty).

Examples

df <- data.frame(
  species = c("Aus bus", "Aus bus"),
  collector = c("Barreira", "Silva"),
  collectorNumber = c("123", "456"),
  herbarium = c("RB", "R"),
  stringsAsFactors = FALSE)
vouchers_from_occ(df)

Read World Database on Protected Areas polygons intersecting an area

Description

Queries the public WDPA ArcGIS FeatureServer for the protected-area polygons whose envelope intersects the bounding box of aoi and returns them as an sf in WGS84 with the same three standardised columns used by protected_areas(): pa_name (WDPA NAME), pa_category (designation / IUCN category) and pa_group (Strict protection for IUCN Ia-III, Sustainable use for IUCN IV-VI, else the reported status), plus all original WDPA attributes.

Usage

wdpa_areas(
  aoi,
  url = wdpa_query_url(),
  marine = c("all", "terrestrial"),
  cache = TRUE,
  cache_dir = NULL,
  quiet = TRUE
)

Arguments

aoi

An sf/sfc polygon or point set (any CRS).

url

WDPA query endpoint (default wdpa_query_url()).

marine

One of "all" (default), "terrestrial" (drop purely marine PAs, MARINE = 2) - useful for terrestrial species screening.

cache, cache_dir

Cache the result on disk (default TRUE; folder mappingAS_pa_cache under tempdir()).

quiet

Passed to sf::st_read() (default TRUE).

Details

Only the AOI's bounding box is requested (server-side envelope filter) and the server's transfer limit is followed with pagination, so this stays light even though WDPA is a global dataset. Results are cached on disk by bounding box. This is the recommended protected-area source for the "amazonia" and "colombia" initiatives (and anywhere outside Brazil), where the ICMBio service does not apply.

Value

An sf of WDPA polygons in EPSG:4326 (possibly zero rows), or NULL if the service could not be read.

Examples


occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
                                    package = "mappingAS"))
sp1 <- occ[occ$species == occ$species[1], ]
pas <- wdpa_areas(calc_eoo(sp1)$hull)  # reads WDPA over the web
unique(pas$pa_name)


Default WDPA ArcGIS FeatureServer query endpoint

Description

The public ArcGIS FeatureServer layer that serves the World Database on Protected Areas (WDPA) polygons, used by wdpa_areas() as a global alternative to the Brazil-only ICMBio Conservation Units. This is the layer behind the ArcGIS Living Atlas "WDPA" item and returns GeoJSON on demand, so no Google Earth Engine or bulk download is required.

Usage

wdpa_query_url()

Value

A length-1 character URL (the /query endpoint).

See Also

https://www.protectedplanet.net/en, wdpa_areas()