geo.tools: grey.area geo tools

geo.toolsR Documentation

grey.area geo tools

Description

Some functions for use with (latitude, longitude) coordinates.

Usage

geoFrame(lat, lon = NULL, ..., pair.lat.lon = TRUE)

geoBearing(lat, lon = NULL, ...)

geoDistance(lat, lon = NULL, units = "m", ...)

geoElevation(
  lat,
  lon = NULL,
  units = "m",
  ...,
  method = "google.elevation",
  n = 10
)

geoDestination(
  lat,
  lon = NULL,
  bearing = NULL,
  distance = NULL,
  units = "m",
  ...
)

geoConvertBNG2LatLon(east, north = NULL, ..., crs = 27700)

geoConvertLatLonDec2Deg(lat, lon = NULL, ..., format = NULL, test = FALSE)

Arguments

lat, lon

Latitudes and longitudes to be used in geographical calculations. Note: This can be supplied as two vectors or as a list or data.frame containing lat and lon vectors.

...

Additional arguments, currently ignored.

pair.lat.lon

(Logical) Should lat and lon be paired? If TRUE (as in default) lat and lon series lengths are matched and extra values are discarded.

units

(Character) The units that results should be reported in. For, geoDistance, geoElevation and geoDestination, the current options are (the default) "m" and "km".

method

(For geoElevation) the elevation method. Currently, the only enabled option is 'google.elevation' which uses the Google Elevation API.

n

(For geoElevation) the single request size limit. Some elevation data request methods cannot handle large numbers of lat, lon at a go. So, where this is case geoElevation generates and merges multiple requests. n sets the maximum number of lat, lon per request.

bearing, distance

(For geoDestination) the bearing (relative to North) and distance to move from the start point lat, lon.

east, north

(For geoConvertBNG2LatLon) Easting and Northing coordinates, respectively.

crs

(For geoConvertBNG2LatLon) the coordinate reference system for supplied easting and northing, by default 27700, the EPSG code for British National Grid coordinates.

format

(For geoConvertLatLonDev2Deg) formatting for supplied lat and lon assumed to be supplied in degrees (deg/min/sec) format. The default NULL assumes lat and lon are not formatted.

test

(For geoConvertLatLonDev2Deg) test supplied lat and lon coordinates before converting. This generates a WARNING only if any look like a suspect case for conversion, e.g a lat > 90, lon > 180, degrees > 60, etc...

Value

geoFrame is data handler used by other geo... functions. It returns a list containing the named components lat and lon. if latitude, longitude pairing has been applied pair.lat.lon = TRUE these components will be the same length.

geoBearing returns a vector of bearings for supplied lat, lon combinations. NOTE: Bearings length will be one less than the length number of lat (or lon) because bearings are measured prior point to latter point.

geoDistance returns a vector of distances between supplied lat, lon points in a supplied series, so again one less the supplied number of points. By default, this will be supplied in meters, but units can be modified as part of the call using, e.g. units = "km" to get distance(s) in kilometers.

geoElevation returns a vector of elevations, one for each lat, lon pair supplied. By default, this will be supplied in meters, but units can be modified as part of the call using, e.g. units = "km" to get elevations(s) in kilometers.

geoDestination returns a list of named lat/lon pairs for the path from the supplied lat/lon start point, assuming the journey described by the supplied bearings and distance.

geoConvertBNG2LatLon converts British National Grid (BNG) Easting/Northing coordinates to (WGS84) Latitude/Longitude coordinates.

geoConvertLatLonDeg2Dem converts Latitude/Longitude coordinates logged in degrees to decimal.

Note

All functions currently require or convert to lat and lon in WGS84 coordinates and conventional decimal format.

geoBearing DETAILS NEEDED.

geoDistance uses the haversine formula to account to the Earth's surface curvature, and uses 6371 km as the radius of earth.

geoElevation uses the Google elevation API to get elevations, so required R to be internet enabled.

geoDestination DETAILS NEEDED.

Author(s)

Karl Ropkins

Examples

#example 1
lat <- 1:10
lon <- 1:10
#get the distance point1 to point2, point2 to point2, etc.
dist <- geoDistance(lat, lon)
#get the bearing point1 to point2, point2 to point2, etc.
bear <- geoBearing(lat, lon)
#reconstruct the journey from start point,
#using distances and bearings
geoDestination(lat[1], lon[1], bear, dist)
#(very nearly...)

karlropkins/grey.area documentation built on Dec. 27, 2024, 7:10 p.m.