proj_trans {PROJ}R Documentation

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:

  • A coordinate matrix containing 2, 3 or 4 columns. If named, expects column names "x", "y" and optionally "z" and/or "m". If not named, columns are assumed in xyzm order. Non-coordinate columns are removed.

  • A data.frame containing coordinates as columns. Expects names "x", "y" and optionally "z" and/or "m". Non-coordinate columns are retained.

  • A data.frame containing a geometry vector which is readable by wk::wk_handle(), including sfc columns.

  • A geometry vector which is readable by wk::wk_handle(), including sfc columns.

source_crs, target_crs

Source/Target CRS definition, coerced with wk::wk_crs_proj_definition()

...

Additional parameters forwarded to wk::wk_handle()

use_z, use_m

Used to declare the output type. Use TRUE to ensure the output has that dimension, FALSE to ensure it does not, and NA to leave the dimension unchanged.

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)


[Package PROJ version 0.5.0 Index]