The function transforms spatial coordinates from original projection (decimal degrees assumed) to another projection.

transform_coord(
  x = NULL,
  lon = NULL,
  lat = NULL,
  new.names = c("lon.utm", "lat.utm"),
  proj.og = "+proj=longlat +datum=WGS84",
  proj.out = "+init=epsg:32633",
  map.type = NULL,
  verbose = FALSE,
  bind = FALSE,
  na = "ignore"
)

Arguments

x

data frame to be transformed. Can be omitted if numeric vectors are assigned to lon and lat.

lon, lat

either a name of the longitude and latitude columns in x or a numeric vector containing longitude and latitude coordinates. Use NULL to guess the longitude and/or latitude columns in x.

new.names

a vector of length 2 specifying the names of transformed longitude and latitude columns, respectively. NULL returns column names from x

proj.og

original proj4string projection. If NULL, the projection is taken from x. x must be a Spatial object in that case.

proj.out

the proj4string projection the coordinates should be transformed to. Defaults to the "svalbard" shape file projection.

map.type

a character string specifying the map type for which coordinates should be transformed to. If NULL (default), proj.out is used to determine the returned projection. See type argument for possible map types. Overrides proj.out.

verbose

if TRUE, the function prints information about the changed projection. Switch to FALSE to make the function silent.

bind

logical. Should only transformed coordinates be returned (FALSE, default) or should x be returned with transformed coordinates (TRUE)?

na

character specifying the NA action for missing coordinates. The "ignore" option ignores the coordinates and returns NAs to transformed coordinates. The "remove" option removes missing values from x returning a message while doing it. Any other character argument will tricker na.fail stopping the function in case of missing coordinates.

Value

Returns a data frame with transformed spatial coordinates

Details

If x is specified, the function guesses longitude and latitude columns from x by default.