latlon_to_xy.Rd
This function converts geographic coordinates (latitude and longitude) into
projected coordinates based on a specified Coordinate Reference System (CRS).
The function can automatically detect the CRS from provided metadata (dataInfo
)
or use a specified CRS code. It is designed to work with datasets obtained
from rerddap::griddap()
but can be used with any geographic data that requires
coordinate transformation.
latlon_to_xy(
dataInfo,
longitude,
latitude,
xName = "rows",
yName = "cols",
crs = NULL
)
Metadata object containing CRS information, typically obtained
from a rerddap::info()
call on a dataset. It should include global attributes
that contain CRS information.
Numeric vector of longitudes to be converted.
Numeric vector of latitudes to be converted.
Name of the longitude coordinate in the output projection. Defaults to 'longitude'.
Name of the latitude coordinate in the output projection. Defaults to 'latitude'.
Optional. A character string specifying the CRS to use for the
projection. This can be an EPSG code (e.g., 'EPSG:4326' for WGS84) or a PROJ
string. If NULL, the function attempts to detect the CRS from dataInfo
.
A matrix with columns corresponding to the projected x and y coordinates
(in the order specified by xName
and yName
). Each row in the matrix
corresponds to a pair of input latitude and longitude values.