Projection of coordinates
projectCoordinates.Rd
Projection of coordinates
Arguments
- mydata
data.table
ordata.frame
containing the coordinates to be projected.- lon
Character vector indicating the name of the column with the longitude values (default 'lon').
- lat
Character vector indicating the name of the column with the latitude values (default 'lat').
- projection
string for UTM projection: EPSGxx, proj4 string, (UTMxx formats accepted).
- inverse
TRUE
if the projection is inverse, e.g. UTM -> lon, lat (default = FALSE).
Value
A data.table
with all the input columns and projected x
, y
coordinates.
If inverse is TRUE
the new columns are called lon
and lat
.
Details
Project geographic coordinates to new Coordinate Reference System (CRS) as
defined in the projection
argument.
If inverse
is TRUE
the projection is to geographic system and the
projection
argument specificies the starting CRS.
Examples
# From latlon to UTM32
mydata <- data.frame(lon = 7.5, lat = 45)
out <- projectCoordinates(mydata, lon = "lon", lat = "lat", projection = "UTM32")
# From UTM32 to latlon
mydata <- data.frame(x = 381777, y = 4984045)
out <- projectCoordinates(mydata, lon = "x", lat = "y",
projection = "EPSG:32632", inverse = TRUE)