View source: R/get_distortion_metrics.R
| get_distortion_metrics | R Documentation |
This function computes Tissot's indicatrix distortion metrics (Snyder 1987,
pp. 20-26) for a grid of points across the extent of data, evaluated in the
CRS of data.
get_distortion_metrics(
data,
centres = c(5, 5),
radius = 100,
method = c("sphere", "ellipsoid")
)
data |
An sf, SpatRaster, or SpatVector object. This has to be projected to the CRS intended to assess. |
centres |
Either a list with elements "lng" and "lat", or a vector of
length 2 with the number of rows/columns for an automatic grid, as in
|
radius |
The length of the probing step used to estimate local
distortion, in metres, used only when |
method |
The Earth model used to compute the distortion metrics, either
|
Distortion metrics can be computed using two different method:
"sphere": for each grid point, the function takes a short step, of
length radius, due north and due east on a sphere with fixed radius. Point
and steps are then projected to the CRS of data, and the distortion metrics
are computed. Because the Earth is not a perfect sphere, this method is less
accurate than the "ellipsoid" method (differences in angular distortion
are usually below 1°), but it does not require the PROJ library and the
PROJ R package installed.
"ellipsoid": distortion metrics are computed using the PROJ R library
via the PROJ::proj_factors() function, using the ellipsoid defined by the
CRS and therefore being more accurate than the "sphere" method. This method
requires the PROJ R package (>= 0.7.0) installed. Currently, the latter
works from binary for Windows and Linux, but not for MacOS. The latter can be
installed from source, but requires the PROJ library to be installed.
The following measures are returned per each grid point: areal_scale, the
ratio of projected to true area (value of 1 means no area distortion, higher
values indicate local inflation, while lower values indicate local
shrinkage), angular_distortion, Snyder's maximum angular deformation in
degrees (a value of 0 degrees means no shape distortion, a value of 180
degrees means complete shape distortion), the semi-major and semi-minor
axes of the indicatrix, and the intersection angle between the projected
meridian and parallel directions (90 degrees indicates no angular
distortion).
A data.frame with one row per grid point: lon, lat (centre of the
point, in EPSG:4326), areal_scale, angular_distortion (degrees),
intersection_angle (degrees), semi_major, and semi_minor.
Snyder, J.P. (1987) Map Projections: A Working Manual. U.S. Geological Survey Professional Paper 1395, pp. 20-26. Washington, D.C.: U.S. Government Printing Office. DOI: 10.3133/pp1395.
Sumner, M.D. (2026) PROJ: Generic Coordinate System Transformations Using 'PROJ'. R package version 0.7.0. https://CRAN.R-project.org/package=PROJ
# load required packages
library(rnaturalearth)
library(sf)
s_america_sf <- ne_countries(continent = "South America", returnclass = "sf")
s_am_equal_area <- suggest_crs(s_america_sf, distortion = "equal_area")
s_america_proj <- st_transform(s_america_sf, s_am_equal_area$proj4)
metrics <- get_distortion_metrics(s_america_proj)
summary(metrics[c("areal_scale", "angular_distortion")])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.