lonlat2map: Convert from longitude and latitude to x-y coordinates
Description
Convert from longitude and latitude to x-y coordinatesUsage
lonlat2map(longitude, latitude,
projection="", parameters=NULL, orientation=NULL)
Arguments
longitude
a vector containing decimal longitudes, or a list containing
items named longitude
and latitude
, in which case the
indicated values are used, and next argument is ignored.
latitude
a vector containing decimal latitude (ignored if
longitude
is a list, as described above).
projection
optional indication of projection. This is normally a
string in the format used by the proj4
package, i.e. starting
with +proj=
. (See the Deprecation notice for
parameters,orientation
See Deprecation notice for
mapPlot
. Value
- A list containing
x
and y
.
Deprecation notice
At the moment of writing, it is still also
possible to specify projections using projection
, parameters
and orientation
in the terminology employed by the mapproj
package. In that case, the calculations are done using that package (if it
is installed). Unfortunately, this method can yield poor results, because
inverse-projection is not handled by mapproj
. For this reason, this
capability is likely to be removed in a future version of oce
. It is
only provided in the present version to give users time to alter their
code. It will be removed sometime in the year 2015.Details
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.See Also
mapLongitudeLatitudeXY
is a safer alternative, if a map has
already been drawn with mapPlot
, because that function cannot
alter an existing projection.Examples
Run this codelibrary(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)
Run the code above in your browser using DataLab