If a projection is already being used (e.g. as set by mapPlot())
then only longitude and latitude should be given, and the
other arguments will be inferred by lonlat2map. This is important
because otherwise, if a new projection is called for, it will ruin any
additions to the existing plot.
Usage
lonlat2map(longitude, latitude, projection = "", debug = getOption("oceDebug"))Arguments
- longitude
one of three choices: (1) a numeric vector containing decimal longitudes, (2) a list containing items named
longitudeandlatitude, or (3) a coastline object, e.g. as created withas.coastline()orread.coastline(). In the second two cases, the values of longitude and latitude are inferred from the first argument, and any supplied value oflatitude(next parameter) is ignored.- latitude
a numeric vector containing decimal latitude (ignored if
longitudeis a list, as described above).- projection
optional indication of projection. This must be character string in the format used by the sf package; see
mapPlot().)- debug
an integer specifying whether debugging information is to be printed during the processing. This is a general parameter that is used by many
ocefunctions. Generally, settingdebug=0turns off the printing, while higher values suggest that more information be printed. If one function calls another, it usually reduces the value ofdebugfirst, so that a user can often obtain deeper debugging by specifying higherdebugvalues.
See also
mapLongitudeLatitudeXY is a safer alternative, if a map has
already been drawn with mapPlot(), because that function cannot
alter an existing projection. map2lonlat() is an inverse to
map2lonlat.
Other functions related to maps:
formatPosition(),
lonlat2utm(),
map2lonlat(),
mapArrows(),
mapAxis(),
mapContour(),
mapCoordinateSystem(),
mapDirectionField(),
mapGrid(),
mapImage(),
mapLines(),
mapLocator(),
mapLongitudeLatitudeXY(),
mapPlot(),
mapPoints(),
mapPolygon(),
mapScalebar(),
mapText(),
mapTissot(),
oceCRS(),
oceProject(),
shiftLongitude(),
usrLonLat(),
utm2lonlat()
Examples
library(oce)
# Cape Split, in the Minas Basin of the Bay of Fundy
cs <- list(longitude = -64.49657, latitude = 45.33462)
xy <- lonlat2map(cs, projection = "+proj=merc")
map2lonlat(xy)
#> $longitude
#> [1] -64.49657
#>
#> $latitude
#> [1] 45.33462
#>