| Title: | Comprehensive Interface to the PROJ Library |
|---|---|
| Description: | Direct access to the PROJ coordinate transformation library (>= 9.6.0), including coordinate transformation, CRS inspection, decomposition, identification, operation discovery, projection factors, and database queries. Uses cpp11 for bindings to the PROJ C API. |
| Authors: | Michael Sumner [aut, cre] |
| Maintainer: | Michael Sumner <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.1 |
| Built: | 2026-10-15 00:47:01 UTC |
| Source: | https://github.com/hypertidy/projr |
Export CRS as PROJ string
proj_as_proj_string(x)proj_as_proj_string(x)
x |
a |
character string
Export CRS as PROJJSON
proj_as_projjson(x)proj_as_projjson(x)
x |
a |
character string (JSON)
Export CRS as WKT
proj_as_wkt( x, type = c("WKT2_2019", "WKT2_2019_SIMPLIFIED", "WKT2_2015", "WKT2_2015_SIMPLIFIED", "WKT1_GDAL", "WKT1_ESRI") )proj_as_wkt( x, type = c("WKT2_2019", "WKT2_2019_SIMPLIFIED", "WKT2_2015", "WKT2_2015_SIMPLIFIED", "WKT1_GDAL", "WKT1_ESRI") )
x |
a |
type |
WKT variant |
character string
proj_as_wkt(proj_crs("EPSG:4326")) proj_as_wkt(proj_crs("EPSG:4326"), type = "WKT1_GDAL")proj_as_wkt(proj_crs("EPSG:4326")) proj_as_wkt(proj_crs("EPSG:4326"), type = "WKT1_GDAL")
Create from any supported representation: EPSG code, PROJ string, WKT, PROJJSON, or database name (e.g. "WGS 84").
proj_crs(x)proj_crs(x)
x |
CRS definition string |
An external pointer to a PROJ PJ object, with class "projr_crs"
proj_crs("EPSG:4326") proj_crs("EPSG:32755") proj_crs("+proj=laea +lon_0=147 +lat_0=-42 +datum=WGS84 +type=crs")proj_crs("EPSG:4326") proj_crs("EPSG:32755") proj_crs("+proj=laea +lon_0=147 +lat_0=-42 +datum=WGS84 +type=crs")
Get the geodetic CRS underlying a projected or compound CRS
proj_crs_get_geodetic_crs(x)proj_crs_get_geodetic_crs(x)
x |
a |
a projr_crs object
proj_crs_get_geodetic_crs(proj_crs("EPSG:32755"))proj_crs_get_geodetic_crs(proj_crs("EPSG:32755"))
Path to the PROJ database
proj_db_path()proj_db_path()
character string
Compute scale, angular distortion, Tissot indicatrix parameters and partial derivatives at given geographic coordinates for a projected CRS.
proj_factors(lon, lat, crs)proj_factors(lon, lat, crs)
lon, lat
|
numeric vectors of geographic coordinates (degrees) |
crs |
projected CRS definition string |
data.frame with distortion metrics
proj_factors(seq(140, 155, by = 5), rep(-42, 4), "+proj=utm +zone=55 +datum=WGS84")proj_factors(seq(140, 155, by = 5), rep(-42, 4), "+proj=utm +zone=55 +datum=WGS84")
Get the area of use of a CRS
proj_get_area_of_use(x)proj_get_area_of_use(x)
x |
a |
list with west, south, east, north, name
proj_get_area_of_use(proj_crs("EPSG:32755"))proj_get_area_of_use(proj_crs("EPSG:32755"))
List database authorities
proj_get_authorities()proj_get_authorities()
character vector
List codes for an authority and type
proj_get_codes(auth, type = "CRS")proj_get_codes(auth, type = "CRS")
auth |
authority name (e.g. "EPSG") |
type |
object type (e.g. "ProjectedCRS", "GeographicCRS", "Ellipsoid") |
character vector
head(proj_get_codes("EPSG", "Ellipsoid"))head(proj_get_codes("EPSG", "Ellipsoid"))
Get ellipsoid parameters
proj_get_ellipsoid(x)proj_get_ellipsoid(x)
x |
a |
list with name, semi_major, semi_minor, inv_flattening,
is_semi_minor_computed
proj_get_ellipsoid(proj_crs("EPSG:4326")) proj_get_ellipsoid(proj_crs("EPSG:4283"))proj_get_ellipsoid(proj_crs("EPSG:4326")) proj_get_ellipsoid(proj_crs("EPSG:4283"))
Get the authority and code of a PROJ object
proj_get_id(x, index = 0L)proj_get_id(x, index = 0L)
x |
a |
index |
zero-based identifier index (usually 0) |
list with authority and code
Get the name of a PROJ object
proj_get_name(x)proj_get_name(x)
x |
a |
character string
Get the type of a PROJ object
proj_get_type(x)proj_get_type(x)
x |
a |
character string
Given a CRS (especially one parsed from WKT), find matching entries in the PROJ database with confidence scores.
proj_identify(x, auth_name = NULL)proj_identify(x, auth_name = NULL)
x |
a |
auth_name |
optional authority to restrict search (e.g. "EPSG") |
data.frame with authority, code, confidence
crs <- proj_crs("+proj=longlat +datum=WGS84 +type=crs") proj_identify(crs)crs <- proj_crs("+proj=longlat +datum=WGS84 +type=crs") proj_identify(crs)
Test if a PROJ object is a CRS
proj_is_crs(x)proj_is_crs(x)
x |
a |
logical
Transforms coordinates between CRS. Supply just x/y for 2D, add z for 3D, add t for 4D. Output list shape mirrors input — you get back only the components you put in.
proj_trans(x, y, z = NULL, t = NULL, source, target)proj_trans(x, y, z = NULL, t = NULL, source, target)
x, y
|
numeric vectors (required) |
z |
numeric vector or NULL |
t |
numeric vector or NULL |
source, target
|
CRS definition strings |
Named list of numeric vectors (x, y, and optionally z, t)
# 2D proj_trans(147:148, c(-42, -45), source = "OGC:CRS84", target = "EPSG:32755") # 3D — just add z proj_trans(147, -42, z = 100, source = "OGC:CRS84", target = "EPSG:4978")# 2D proj_trans(147:148, c(-42, -45), source = "OGC:CRS84", target = "EPSG:32755") # 3D — just add z proj_trans(147, -42, z = 100, source = "OGC:CRS84", target = "EPSG:4978")
Handles densification, antimeridian crossings, and polar regions correctly.
proj_trans_bounds(xmin, ymin, xmax, ymax, source, target, densify_pts = 21L)proj_trans_bounds(xmin, ymin, xmax, ymax, source, target, densify_pts = 21L)
xmin, ymin, xmax, ymax
|
extent in source CRS |
source, target
|
CRS definition strings |
densify_pts |
number of points per edge for densification |
Named numeric vector: xmin, ymin, xmax, ymax
proj_trans_bounds(140, -50, 155, -35, "OGC:CRS84", "EPSG:32755")proj_trans_bounds(140, -50, 155, -35, "OGC:CRS84", "EPSG:32755")
Transform xy coordinates
proj_trans_xy(x, y, source, target)proj_trans_xy(x, y, source, target)
x, y
|
numeric vectors of coordinates (degrees for geographic CRS) |
source, target
|
CRS definition strings (EPSG codes, WKT, PROJ strings) |
Named list with x and y numeric vectors
proj_trans_xy(147:148, c(-42, -45), "OGC:CRS84", "EPSG:32755")proj_trans_xy(147:148, c(-42, -45), "OGC:CRS84", "EPSG:32755")
Transform xyz coordinates
proj_trans_xyz(x, y, z, source, target)proj_trans_xyz(x, y, z, source, target)
x, y
|
numeric vectors of coordinates (degrees for geographic CRS) |
z |
numeric vector of elevation/vertical values |
source, target
|
CRS definition strings (EPSG codes, WKT, PROJ strings) |
Named list with x, y, and z numeric vectors
proj_trans_xyz(147, -42, 100, "OGC:CRS84", "EPSG:4978")proj_trans_xyz(147, -42, 100, "OGC:CRS84", "EPSG:4978")
Transform xyzt coordinates
proj_trans_xyzt(x, y, z, t, source, target)proj_trans_xyzt(x, y, z, t, source, target)
x, y
|
numeric vectors of coordinates (degrees for geographic CRS) |
z |
numeric vector of elevation/vertical values |
t |
numeric vector of time values (decimal year for dynamic CRS) |
source, target
|
CRS definition strings (EPSG codes, WKT, PROJ strings) |
Named list with x, y, z, and t numeric vectors
Transform coordinates with explicit direction
proj_transform( x, y, z = NULL, t = NULL, source, target, direction = c("forward", "inverse", "identity") )proj_transform( x, y, z = NULL, t = NULL, source, target, direction = c("forward", "inverse", "identity") )
x, y
|
numeric vectors (required) |
z |
numeric vector or NULL |
t |
numeric vector or NULL |
source, target
|
CRS definition strings |
direction |
One of |
Named list of numeric vectors
# Forward pt <- proj_transform(147, -42, source = "OGC:CRS84", target = "EPSG:32755") # Inverse — swap conceptually without swapping source/target proj_transform(pt$x, pt$y, source = "OGC:CRS84", target = "EPSG:32755", direction = "inverse")# Forward pt <- proj_transform(147, -42, source = "OGC:CRS84", target = "EPSG:32755") # Inverse — swap conceptually without swapping source/target proj_transform(pt$x, pt$y, source = "OGC:CRS84", target = "EPSG:32755", direction = "inverse")
PROJ version info
proj_version()proj_version()
list with version, searchpath, paths