Skip to contents

inv_project() transforms geospatial x/y coordinates to longitude/latitude in the same geographic coordinate system used by the given projected spatial reference system. The output long/lat can optionally be set to a specific geographic coordinate system by specifying a well known name (see Details).

Usage

inv_project(pts, srs, well_known_gcs = "")

Arguments

pts

A two-column data frame or numeric matrix containing geospatial x/y coordinates.

srs

Character string in OGC WKT format specifying the projected spatial reference system for pts.

well_known_gcs

Optional character string containing a supported well known name of a geographic coordinate system (see Details for supported values).

Value

Numeric array of longitude, latitude. An error is raised if the transformation cannot be performed.

Details

By default, the geographic coordinate system of the projection specified by srs will be used. If a specific geographic coordinate system is desired, then well_known_gcs can be set to one of the values below:

EPSG:nwhere n is the code of a geographic coordinate system
WGS84same as EPSG:4326
WGS72same as EPSG:4322
NAD83same as EPSG:4269
NAD27same as EPSG:4267
CRS84same as WGS84
CRS72same as WGS72
CRS27same as NAD27

The returned array will always be in longitude, latitude order (traditional GIS order) regardless of the axis order defined for the names above.

See also

Examples

pt_file <- system.file("extdata/storml_pts.csv", package="gdalraster")
## id, x, y in NAD83 / UTM zone 12N
pts <- read.csv(pt_file)
print(pts)
#>    id   xcoord  ycoord
#> 1   1 324650.9 5103344
#> 2   2 324171.0 5103034
#> 3   3 323533.4 5103329
#> 4   4 325220.0 5103508
#> 5   5 325703.1 5102377
#> 6   6 326297.8 5103924
#> 7   7 325520.4 5104146
#> 8   8 326247.7 5102506
#> 9   9 327711.7 5104476
#> 10 10 324181.7 5103901
inv_project(pts[,-1], epsg_to_wkt(26912))
#>            [,1]     [,2]
#>  [1,] -113.2671 46.06118
#>  [2,] -113.2732 46.05827
#>  [3,] -113.2815 46.06076
#>  [4,] -113.2598 46.06280
#>  [5,] -113.2531 46.05276
#>  [6,] -113.2460 46.06682
#>  [7,] -113.2561 46.06862
#>  [8,] -113.2461 46.05405
#>  [9,] -113.2279 46.07214
#> [10,] -113.2733 46.06607
inv_project(pts[,-1], epsg_to_wkt(26912), "NAD27")
#>            [,1]     [,2]
#>  [1,] -113.2662 46.06126
#>  [2,] -113.2723 46.05835
#>  [3,] -113.2806 46.06084
#>  [4,] -113.2589 46.06288
#>  [5,] -113.2522 46.05283
#>  [6,] -113.2451 46.06689
#>  [7,] -113.2552 46.06869
#>  [8,] -113.2452 46.05413
#>  [9,] -113.2270 46.07222
#> [10,] -113.2724 46.06615