PROJ

What is PROJ?

Generic map projection transformations on raw data.

We use the PROJ library to perform projection transformations on raw data. We can use a matrix or data frame of 2, 3, or 4 columns and these are assumed (if present) to be “x”, “y”, “z”, and “t” (time: modern transformations allow a temporal component as the shape of the earth and our models of it do change over time).

The transformation idiom used is 1) provide raw coordinates; 2) specify their source projection; 3) specify their target projection.

We don’t enter into the coordinate order debacle of the OGC for longitude, latitude. Projection strings are able to carry this information, and passing in the right data is the responsibility of the user.

Why PROJ?

This package was created to leverage the modern transformation capabilities of PROJ itself from version 6 and above. There’s no other package in R that allows generic transformations directly from the PROJ library, and this package provides that along with these goals:

What systems are supported?

How to use PROJ?

Get the package installed, load it and use the function proj_trans_generic().

If you don’t have system PROJ version 6 (or higher) the function will fail.

library(PROJ)
proj_trans_generic(cbind(c(0, 147), c(0, -42), 0), target = "+proj=laea +datum=WGS84", source = "WGS84")
#> Error in proj_trans_generic(cbind(c(0, 147), c(0, -42), 0), target = "+proj=laea +datum=WGS84", : x coordinates must be 2-columns

Note that various forms of projection string are supported, we can use PROJ.4 style (as per target above), bare names from EPSG (as per source above), full-blown WKT2 strings, or ‘auth:code’ forms such as “epsg:3857”. (Note that “+init=…” forms cannot be used in 6 or above).

The goal is for the reproj package to wrap this package. In time that will be the easiest way to run coordinate transformations with PROJ for versions 4, 5, 6, 7 or above.

To find out if your system supports PROJ 6 (or higher) use the function ok_proj6().

ok_proj6()
#> [1] TRUE