| 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_occurrencesImport points from csv/xlsx/shapefile.
assess_speciesFull pipeline (EOO, AOO, conversion).
calc_eoo,calc_aooRange metrics only.
summarise_conversionConvert class areas to % converted.
map_species,plot_conversionVisual output.
run_appLaunch 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:
Antônio Lucas Barreira barreira_rodrigues@hotmail.com [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/lucasbarreirageo/mappingAS/issues
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 |
initiative |
Land-cover product. A MapBiomas initiative -
|
year |
Integer MapBiomas year. |
collection |
Integer MapBiomas collection number. |
backend |
Habitat backend: |
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): |
cell_km |
AOO grid cell size in km (default |
subpop |
Logical; if |
subpop_resol_km |
Circular-buffer radius in km for the subpopulation
estimate. |
loc_km |
Grid cell size in km for the number-of-locations estimate
(default |
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_method |
How protected areas enter the number-of-locations estimate
when |
mapbiomas |
Logical; if |
fire |
Logical; if |
fire_collection, fire_host_collection |
Fire collection number (default
|
protected |
Logical; if |
pa_src |
Optional local protected-area vector file ( |
src |
Optional MapBiomas LULC GeoTIFF for the local backend. |
fire_src |
Optional MapBiomas Fire GeoTIFF (overrides the public URL). |
water_in_denominator |
Passed to |
area_max_pixels |
Pixel budget for the land-cover area read on the
local backend (default |
decline, extreme_fluctuation, severe_fragmentation |
Expert inputs for the
Criterion B sub-criteria, applied by |
min_records |
Minimum records required to attempt an assessment. |
verbose |
Logical; print progress (default |
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
-
eoo_fire,aoo_fire).
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 |
species |
Species name (default: the first assessed). |
lang |
Report language: |
output |
One of |
file |
Target path for |
cover_series |
Optional land-cover time series for this species (as from
|
fire_series |
Optional burned-area time series (as from
|
applied_category, applied_code |
Optional applied Criterion B category
(e.g. |
figures |
Logical; for |
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 |
cell_km |
Grid cell side length in kilometres (default |
n_rep |
Integer; number of randomly translated grids to test (default
|
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 |
segmentize_km |
Numeric edge length, in kilometres, used to densify the
hull edges along great circles (default |
Details
Degenerate cases are handled so the function never errors:
With fewer than three unique points a polygon cannot be built and the EOO is
NA.When the unique points are perfectly collinear (they would form a line of area zero) a small amount of noise is added to the coordinates (
jitter), exactly as in ConR, so that a valid polygon can still be produced.If, for any other reason, a valid polygon still cannot be built, the EOO is returned as
NArather than throwing an error.
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 |
grid_km |
Grid cell side length in kilometres (default |
n_rep |
Integer; number of randomly translated grids to test (default
|
protected |
Optional protected-area layer (an |
method_protected |
How protected areas enter the count when
|
cell_scale |
Optional numeric fraction for the sliding-scale cell size:
the cell side becomes |
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:
-
method_protected = "no_more_than_one"(default): every protected area holding at least one occurrence counts as exactly one location (all occurrences within a protected area share a location); occurrences outside protected areas are gridded as usual. The total is (occupied cells outside) + (number of protected areas with occurrences). -
method_protected = "other": occurrences inside protected areas are gridded separately from those outside, and the two counts are added. Two occurrences closer than the cell size are then still counted as separate locations when one is inside and the other outside a protected area.
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 |
resol_km |
Circle radius in kilometres. |
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
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 |
species |
Optional species name (or vector). |
range |
|
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 |
years |
Integer vector of years. If |
collection |
Integer MapBiomas collection. |
initiative |
One of |
backend |
|
src |
Optional GeoTIFF path/URL for the local backend (overrides the public per-year URL). |
by |
|
include_not_observed |
Logical; keep the "Not Observed" class
(default |
verbose |
Logical; print progress (default |
max_pixels |
Pixel budget for each year's local area read (default
|
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 |
dir |
Output directory (created if it does not exist). Default
|
layer_prefix |
File/layer name prefix. Default |
what |
Which ranges to export: |
format |
|
crs |
Output CRS (default |
aoo_as |
|
class_csv |
If |
zip |
If |
quiet |
Passed to |
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:
-
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. -
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 |
species |
Species name (default: the first assessed). |
lang |
Factsheet language: |
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. |
countries, life_form, substrate, habitat, biome, vegetation |
The "Supporting information" block, all optional free text. |
land_use, conservation_units |
Optional overrides. When left |
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 |
applied_category, applied_code |
Optional applied Criterion B category
(e.g. |
map |
Logical; embed the distribution map (occurrence points, EOO, AOO
and land cover). Default |
map_interactive |
Logical; when |
top_n_threats |
Number of anthropic land-cover classes to show in the
"top anthropic activities" chart (default |
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 |
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 |
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 |
year |
Integer year (ignored when |
product |
|
fire_collection |
Fire collection number (default |
host_collection |
Initiative folder hosting the fire data
(default |
src |
Optional GeoTIFF path/URL overriding the built fire URL. |
mask, cache, cache_dir |
Passed to |
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 |
years |
Integer vector (default |
fire_collection |
Fire collection number (default |
host_collection |
Initiative folder hosting the fire data
(default |
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 |
species |
Species name (default: first assessed). |
range |
|
years, verbose |
Passed to |
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 ( |
n_locations |
Estimated number of locations ( |
severe_fragmentation |
Logical; |
decline |
Logical; |
extreme_fluctuation |
Logical; |
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:
-
(a) severely fragmented or number of locations
\le1 (CR), 5 (EN) or 10 (VU); -
(b) continuing decline (in EOO, AOO, area/extent/quality of habitat, number of locations/subpopulations, or mature individuals);
-
(c) extreme fluctuations.
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
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 |
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 |
species |
Species name to plot (default: first assessed). |
mapbiomas |
Logical; overlay the MapBiomas raster (default |
fire |
Logical; overlay the MapBiomas Fire accumulated layer
(default |
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 |
lang |
Legend language: |
clip |
Geometry the rasters are clipped to: |
protected |
Logical; overlay protected areas. Uses the protected-area
layer already stored by |
pa_src |
Optional local protected-area vector file for the overlay (offline). |
pa_occ_only |
Logical; when |
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 |
species |
Species name (default: first assessed). |
mapbiomas |
Logical; draw the MapBiomas raster layer (default |
fire |
Logical; draw the MapBiomas Fire frequency layer (number
of years burned, 1985-2024). With |
src |
Optional local path / URL to a MapBiomas GeoTIFF (same as in
|
max_pixels |
Target maximum raster size (longest side, in pixels) for the
display layer (default |
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 |
title |
Optional plot title (default: the species name). |
lang |
Legend language: |
clip |
Geometry the rasters are clipped to: |
protected |
Logical; overlay protected areas on the publishable map
(default |
pa_src |
Optional local protected-area vector file for the overlay (offline). |
pa_occ_only |
Logical; when |
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 |
tooltip |
Aesthetics passed to |
... |
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 |
year |
Integer year (default |
collection |
Integer MapBiomas collection id (default |
version |
Asset version string for the public LULC collection
(default |
asset |
Earth Engine |
scale |
Nominal pixel scale in metres for the reduction (default
|
max_pixels |
Maximum pixels for the server-side reduction
(default |
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 |
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 |
|
fire_collection |
Fire collection number (default |
host_collection |
Initiative folder hosting the fire data
(default |
period |
Two-integer accumulated span (default |
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 |
One of the keys of |
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 |
One of the keys of |
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 |
collection |
Integer collection number. Interpreted together with
|
initiative |
One of the keys of |
by |
One of |
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 |
year |
Integer year (default |
collection |
Integer collection number. |
initiative |
One of |
src |
Optional path or URL to a MapBiomas GeoTIFF. If |
mask |
Logical; if |
cache |
Logical; if |
cache_dir |
Directory for the windowed-crop cache (default a
|
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. |
initiative |
One of the keys of |
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 |
One of the keys of |
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 |
species |
Optional species name(s); |
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 |
class_label |
The |
model |
ggtrendline model, one of |
title |
Optional plot title. When |
lang |
Axis/title language: |
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 |
species |
Species name (default: first). |
lang |
Label language: |
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 |
species |
Optional species name. |
by |
|
lang |
|
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 |
title |
Optional title (built from attributes when |
lang |
Label language: |
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 |
species |
Species name (default: first). |
lang |
Label language: |
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 |
title |
Optional plot title. If |
legend |
Logical; draw the class legend (default |
lang |
Legend language: |
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 |
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 |
quiet |
Passed to |
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
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. |
crs |
Input CRS for tabular coordinates (default |
sheet |
For Excel inputs, the sheet name or index (default first sheet). |
sep |
For delimited text, the field separator. If |
dec |
Decimal mark for delimited text. If |
encoding |
File encoding for delimited text (default |
default_species |
Species label used when no species column is found
(default |
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
|
max_upload_mb |
Maximum size, in megabytes, of a file that can be
uploaded in the app (default |
... |
Passed to |
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 |
year |
Integer year (2017-2023, default |
src |
Optional path/URL to a single Esri LULC GeoTIFF (ends in
|
base_url |
Base URL of the public bucket (see |
mask |
Logical; if |
cache |
Logical; cache the windowed crops on disk (default |
cache_dir |
Directory for the crop cache (default under |
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. |
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 |
Value
A length-1 character URL of the form <base>/<tile>_<year>.tif.
See Also
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 |
collection |
Integer collection number (default |
initiative |
One of |
water_in_denominator |
Logical; if |
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 |
range_km2 |
Total range area (km^2). If |
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 |
pa |
A UC |
eoo, aoo |
The |
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 |
species |
Species name (default: first assessed species). |
range |
|
years, by, src, verbose |
Passed to |
max_pixels |
Pixel budget per year, passed to
|
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 |
species |
Optional species name (or vector) to filter the rows before
building the vouchers, matched against the |
voucher_col, collector_col, number_col, herbarium_col |
Optional column
names overriding the automatic detection. Set a column to |
unique |
Collapse duplicate vouchers to a single entry (default
|
sort |
Sort the returned vouchers alphabetically (default |
Details
Two strategies are tried, in order:
If a ready-made voucher column exists (e.g.
voucher,exsiccata,material) its non-empty values are used verbatim.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 |
url |
WDPA query endpoint (default |
marine |
One of |
cache, cache_dir |
Cache the result on disk (default |
quiet |
Passed to |
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).