View source: R/transform_coord.R
transform_coord | R Documentation |
Transforms spatial coordinates from original projection (decimal degrees assumed) to another projection.
transform_coord(
x = NULL,
lon = NULL,
lat = NULL,
new.names = "auto",
rotate = FALSE,
proj.in = 4326,
proj.out = NULL,
verbose = FALSE,
bind = FALSE,
na = "ignore"
)
x |
Data frame to be transformed. Can be omitted if numeric vectors are assigned to |
lon , lat |
Either a name of the longitude and latitude columns in |
new.names |
Character vector of length 2 specifying the names of transformed longitude and latitude columns, respectively. Alternatively |
rotate |
Logical indicating whether the projected maps should be rotated to point towards the pole relative to the mid-longitude limit. |
proj.in |
The original |
proj.out |
Character. Either |
verbose |
Logical indicating whether information about the projection should be returned as message. Set to |
bind |
logical. Should only transformed coordinates be returned ( |
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 |
If x
is specified, the function guesses longitude and latitude columns from x
by default.
Returns a data frame with transformed spatial coordinates.
Mikko Vihtakari
Other basemap functions:
basemap()
,
qmap()
,
shapefile_list()
# Coordinates are automatically transformed to the pre-made shapefile
# projections:
x <- data.frame(lon = c(-150, 150), lat = c(60, 90))
transform_coord(x)
transform_coord(x, bind = TRUE)
x <- data.frame(lon = c(-150, 150), lat = c(20, 50))
transform_coord(x, bind = TRUE) # no transformation required.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.