Package 'PROJ'

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)
Maintainer: Michael D. Sumner <mdsumner@gmail.com>
License: GPL-3
Version: 0.4.5
Built: 2024-01-31 07:49:40 UTC
Source: CRAN

Help Index


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

if (ok_proj6()) {
cat(proj_crs_text("OGC:CRS84", format = 0L))
proj_crs_text("OGC:CRS84", 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 a set of coordinates with 'PROJ'

Description

A raw interface to 'proj_trans' in 'PROJ => 6', if it is available.

Usage

proj_trans(x, target, ..., source = NULL, z_ = NULL, t_ = NULL)

Arguments

x

input coordinates (x,y, list or matrix see z_ and t_)

target

projection for output coordinates

...

ignored

source

projection of input coordinates (must be named i.e. 'source = "<some proj string"' can't be used in positional form)

z_

optional z coordinate vector

t_

optional t coordinate vector

Details

Input 'x' is assumed to be 2-columns of "x", then "y" coordinates. If "z" or "t" is required pass these in as named vectors with "z_" and "t_". For simplifying reasons z_ and t_ must always match the length of x y. Both default to 0, and are automatically recycled to the number of rows in x.

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

list of transformed coordinates, with 4- or 2-elements x_, y_, z_, t_

References

see the PROJ library documentation for details on the underlying functionality

Examples

if (ok_proj6()) {
 proj_trans(cbind(147, -42), "+proj=laea", source = "OGC:CRS84")
 proj_trans(cbind(147, -42), z_ = -2, "+proj=laea", source = "OGC:CRS84")
 proj_trans(cbind(147, -42), z_ = -2, t_ = 1, "+proj=laea", source = "OGC:CRS84")
 }

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.