Skip to contents

A diagnostic and exploration tool: pass any CRS string and get back every representation PROJ can produce. Useful for verifying that a string is recognised as a CRS (not just a coordinate operation) and for converting between WKT variants, PROJ strings, and PROJJSON.

Usage

crs_describe(definition)

Arguments

definition

Character string: EPSG code ("EPSG:4326"), WKT, or PROJ string. For bare +proj= strings, append +type=crs to force CRS interpretation; without it PROJ treats the string as a coordinate operation, which lacks datum information.

Value

A named list with elements input, id, description, definition, wkt2_2019, wkt2_2019_simplified, wkt1_gdal, wkt1_esri, proj5, proj4, projjson, error. Missing representations are NA_character_.

Examples

d <- crs_describe("EPSG:3857")
cat(d$wkt2_2019_simplified)
#> PROJCRS["WGS 84 / Pseudo-Mercator",
#>     BASEGEOGCRS["WGS 84",
#>         ENSEMBLE["World Geodetic System 1984 ensemble",
#>             MEMBER["World Geodetic System 1984 (Transit)"],
#>             MEMBER["World Geodetic System 1984 (G730)"],
#>             MEMBER["World Geodetic System 1984 (G873)"],
#>             MEMBER["World Geodetic System 1984 (G1150)"],
#>             MEMBER["World Geodetic System 1984 (G1674)"],
#>             MEMBER["World Geodetic System 1984 (G1762)"],
#>             MEMBER["World Geodetic System 1984 (G2139)"],
#>             MEMBER["World Geodetic System 1984 (G2296)"],
#>             ELLIPSOID["WGS 84",6378137,298.257223563],
#>             ENSEMBLEACCURACY[2.0]],
#>         UNIT["degree",0.0174532925199433]],
#>     CONVERSION["Popular Visualisation Pseudo-Mercator",
#>         METHOD["Popular Visualisation Pseudo Mercator"],
#>         PARAMETER["Latitude of natural origin",0],
#>         PARAMETER["Longitude of natural origin",0],
#>         PARAMETER["False easting",0],
#>         PARAMETER["False northing",0]],
#>     CS[Cartesian,2],
#>         AXIS["easting (X)",east],
#>         AXIS["northing (Y)",north],
#>         UNIT["metre",1],
#>     USAGE[
#>         SCOPE["Web mapping and visualisation."],
#>         AREA["World between 85.06°S and 85.06°N."],
#>         BBOX[-85.06,-180,85.06,180]],
#>     ID["EPSG",3857]]

# Gotcha: bare PROJ string is treated as an *operation*, not a CRS.
# It has no WKT1 form.
crs_describe("+proj=laea")$wkt1_gdal
#> [1] NA

# Fix: add +type=crs
crs_describe("+proj=laea +datum=WGS84 +type=crs")$wkt1_gdal
#> [1] "PROJCS[\"unknown\",\n    GEOGCS[\"unknown\",\n        DATUM[\"WGS_1984\",\n            SPHEROID[\"WGS 84\",6378137,298.257223563,\n                AUTHORITY[\"EPSG\",\"7030\"]],\n            AUTHORITY[\"EPSG\",\"6326\"]],\n        PRIMEM[\"Greenwich\",0,\n            AUTHORITY[\"EPSG\",\"8901\"]],\n        UNIT[\"degree\",0.0174532925199433,\n            AUTHORITY[\"EPSG\",\"9122\"]]],\n    PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],\n    PARAMETER[\"latitude_of_center\",0],\n    PARAMETER[\"longitude_of_center\",0],\n    PARAMETER[\"false_easting\",0],\n    PARAMETER[\"false_northing\",0],\n    UNIT[\"metre\",1,\n        AUTHORITY[\"EPSG\",\"9001\"]],\n    AXIS[\"Easting\",EAST],\n    AXIS[\"Northing\",NORTH]]"