Title: | Generic Coordinate System Transformations Using 'PROJ' |
---|---|
Description: | A wrapper around the generic coordinate transformation software 'PROJ' that transforms coordinates from one coordinate reference system ('CRS') to another. This includes cartographic projections as well as geodetic transformations. The intention is for this package to be used by user-packages such as 'reproj', and that the older 'PROJ.4' and version 5 pathways be provided by the 'proj4' package. |
Authors: | Michael D. Sumner [aut, cre] , Jeroen Ooms [ctb] (provided PROJ library support on Windows, and assistance with Windows configuration), Simon Urbanek [cph, ctb] (wrote original code versions for PROJ version 6), Dewey Dunnington [ctb] (key code contributions), Anthony North [ctb] |
Maintainer: | Michael D. Sumner <[email protected]> |
License: | GPL-3 |
Version: | 0.5.0 |
Built: | 2024-12-09 03:59:11 UTC |
Source: | https://github.com/hypertidy/PROJ |
Test for availability of 'PROJ' system library version 6 or higher.
ok_proj6()
ok_proj6()
On unix-alikes, this function is run in .onLoad()
to check that version 6 functionality is
available. On Windows, the load process sets the data file location with the version 6 API, and that
is used as a test instead.
If 'PROJ' library version 6 is not available, the package still compiles and installs but is not functional.
The lack of function can be simulated by setting
options(reproj.mock.noproj6 = TRUE)
, designed for use with the reproj package.
logical, TRUE
if the system library 'PROJ >= 6'
ok_proj6()
ok_proj6()
Input any accepted format of 'PROJ' coordinate reference system specification. Return value is a string in the requested format.
proj_crs_text(source, format = 0L)
proj_crs_text(source, format = 0L)
source |
input projection specification one of ('PROJ4', 'WKT2', 'EPSG', 'PROJJSON', ... see the library documentation link in Details) |
format |
integer, 0 for 'WKT', 1 for 'PROJ', 2 for 'PROJJSON' |
This function requires PROJ version 6.0 or higher to be useful. If not, this function simply returns 'NA'.
See the library documentation for details on input and output formats.
character string in requested format
Note that a PROJ string is not a full specification, in particular this means that a string like "+proj=laea" cannot be converted to full WKT, because it is technically a transformation step not a crs. To get the full WKT form use a string like "+proj=laea +type=crs".
cat(proj_crs_text("EPSG:4326", format = 0L)) proj_crs_text("EPSG:4326", format = 1L) south55 <- "+proj=utm +zone=55 +south +ellps=GRS80 +units=m +no_defs +type=crs" proj_crs_text(proj_crs_text(south55), 1L)
cat(proj_crs_text("EPSG:4326", format = 0L)) proj_crs_text("EPSG:4326", format = 1L) south55 <- "+proj=utm +zone=55 +south +ellps=GRS80 +units=m +no_defs +type=crs" proj_crs_text(proj_crs_text(south55), 1L)
Transforms all coordinates in x
using wk::wk_handle()
and proj_trans_create()
.
proj_trans(x, target_crs, source_crs = NULL, ..., use_z = NA, use_m = NA)
proj_trans(x, target_crs, source_crs = NULL, ..., use_z = NA, use_m = NA)
x |
Input geometry/geography. May take any of the following forms:
|
source_crs , target_crs
|
Source/Target CRS definition, coerced with |
... |
Additional parameters forwarded to |
use_z , use_m
|
Used to declare the output type. Use |
Values that are detected out of bounds by library PROJ are allowed, we return Inf
in this case, rather than the error "tolerance condition error".
Transformed geometries whose format is dependent on input.
see the PROJ library documentation for details on the underlying functionality
proj_trans(cbind(147, -42), "+proj=laea +type=crs", "EPSG:4326") proj_trans(cbind(147, -42, -2), "+proj=laea +type=crs", "EPSG:4326") proj_trans(cbind(147, -42, -2, 1), "+proj=laea +type=crs", "EPSG:4326") proj_trans(wk::xy(147, -42, crs = "EPSG:4326"), "+proj=laea +type=crs") proj_trans(wk::wkt("POLYGON ((1 1, 0 1, 0 0, 1 0, 1 1))", crs = "EPSG:4326"), 3112)
proj_trans(cbind(147, -42), "+proj=laea +type=crs", "EPSG:4326") proj_trans(cbind(147, -42, -2), "+proj=laea +type=crs", "EPSG:4326") proj_trans(cbind(147, -42, -2, 1), "+proj=laea +type=crs", "EPSG:4326") proj_trans(wk::xy(147, -42, crs = "EPSG:4326"), "+proj=laea +type=crs") proj_trans(wk::wkt("POLYGON ((1 1, 0 1, 0 0, 1 0, 1 1))", crs = "EPSG:4326"), 3112)
Creates a transformation object that transforms coordinates in a wk pipeline.
proj_trans_create(source_crs, target_crs, use_z = NA, use_m = NA)
proj_trans_create(source_crs, target_crs, use_z = NA, use_m = NA)
source_crs , target_crs
|
Source/Target CRS definition, coerced with |
use_z , use_m
|
Used to declare the output type. Use |
A PROJ transformation object
(trans <- proj_trans_create("EPSG:4326", "EPSG:3857")) wk::wk_transform(wk::xy(1:5, 1:5), trans) library(wk) (invtrans <- wk_trans_inverse(trans)) h <- 1852 * 60 ## the stretch of Mercator to a square wk::wk_transform(wk::xy(c(-h * 180, 0, h * 180), c(-h * 180,0, h * 180)), invtrans)
(trans <- proj_trans_create("EPSG:4326", "EPSG:3857")) wk::wk_transform(wk::xy(1:5, 1:5), trans) library(wk) (invtrans <- wk_trans_inverse(trans)) h <- 1852 * 60 ## the stretch of Mercator to a square wk::wk_transform(wk::xy(c(-h * 180, 0, h * 180), c(-h * 180,0, h * 180)), invtrans)
This function returns NA if PROJ lib is not available.
proj_version()
proj_version()
character string (major.minor.patch)
proj_version()
proj_version()
A copy of the xymap data set from the quadmesh package.
A matrix of longitude/latitude values of the world coastline.