Title: | Generic Coordinate System Transformations Using 'PROJ' |
Version: | 0.6.0 |
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. |
Depends: | R (≥ 3.0.2) |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | lifecycle, wk |
LinkingTo: | wk |
Suggests: | testthat (≥ 3.0.0), spelling, knitr, rmarkdown, sf |
URL: | https://github.com/hypertidy/PROJ, https://hypertidy.github.io/PROJ/ |
BugReports: | https://github.com/hypertidy/PROJ/issues |
Language: | en-US |
VignetteBuilder: | knitr |
SystemRequirements: | PROJ (>= 6.3.1) |
RoxygenNote: | 7.3.2 |
Config/testthat/edition: | 3 |
NeedsCompilation: | yes |
Packaged: | 2025-04-03 00:07:19 UTC; mdsumner |
Author: | Michael D. Sumner |
Maintainer: | Michael D. Sumner <mdsumner@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-04-03 02:30:02 UTC |
PROJ: 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.
The goal of PROJ is to provide generic coordinate system transformations in R without requiring bespoke formats for storing basic data.
I. Functions
ok_proj6 determine if PROJ version >=6 is available
proj_trans a light wrapper around the underlying transformation functionality of PROJ version 6 (or higher)
proj_crs_text generate PROJ crs strings from input
proj_version report PROJ lib version if available and >= 6.3.1
|
Author(s)
Maintainer: Michael D. Sumner mdsumner@gmail.com (ORCID)
Other contributors:
Jeroen Ooms (provided PROJ library support on Windows, and assistance with Windows configuration) [contributor]
Simon Urbanek (wrote original code versions for PROJ version 6) [copyright holder, contributor]
Dewey Dunnington (key code contributions) [contributor]
Anthony North [contributor]
See Also
Useful links:
Report bugs at https://github.com/hypertidy/PROJ/issues
Is 'PROJ library >= 6' available
Description
Test for availability of 'PROJ' system library version 6 or higher.
Usage
ok_proj6()
Details
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.
Value
logical, TRUE
if the system library 'PROJ >= 6'
Examples
ok_proj6()
Generate a projection string.
Description
Input any accepted format of 'PROJ' coordinate reference system specification. Return value is a string in the requested format.
Usage
proj_crs_text(source, format = 0L)
Arguments
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' |
Details
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.
Value
character string in requested format
warning
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".
Examples
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)
Transform coordinates
Description
Transforms all coordinates in x
using wk::wk_handle()
and proj_trans_create()
.
Usage
proj_trans(x, target_crs, source_crs = NULL, ..., use_z = NA, use_m = NA)
Arguments
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 |
Details
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".
Value
Transformed geometries whose format is dependent on input.
References
see the PROJ library documentation for details on the underlying functionality
Examples
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)
Create a transformation object
Description
Creates a transformation object that transforms coordinates in a wk pipeline.
Usage
proj_trans_create(source_crs, target_crs, use_z = NA, use_m = NA)
Arguments
source_crs , target_crs |
Source/Target CRS definition, coerced with |
use_z , use_m |
Used to declare the output type. Use |
Value
A PROJ transformation object
Examples
(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)
Report PROJ library version
Description
This function returns NA if PROJ lib is not available.
Usage
proj_version()
Value
character string (major.minor.patch)
Examples
proj_version()
xymap data for testing
Description
A copy of the xymap data set from the quadmesh package.
Details
A matrix of longitude/latitude values of the world coastline.