Coordinates
Coordinates
LonLat
LonLat(lon, lat) is GlobalGrids’ coordinate type — a point on the Earth’s surface in degrees (EPSG:4326). It implements GeoInterface’s PointTrait, so it works with plotting and spatial libraries.
using GlobalGrids
p = LonLat(-75.0, 54.0)
p.lon # -75.0
p.lat # 54.0
p[1] # -75.0 (indexable)
p[2] # 54.0A LonLat can also be constructed from a tuple:
LonLat((1.0, 2.0))Distance and Bearings
haversine(a, b)— great-circle distance in meters using the Haversine formula.azimuth(a, b)— initial bearing fromatob, degrees clockwise from North.destination(origin, azimuth°, dist_m)— destination point at the given azimuth and distance.
using GlobalGrids
a = LonLat(-75.0, 54.0)
b = LonLat(-80.0, 50.0)
GlobalGrids.haversine(a, b) # distance in meters
GlobalGrids.azimuth(a, b) # bearing in degrees
GlobalGrids.destination(a, 0.0, 111_195) # ~1° northThese functions also work directly on cell types:
c1 = H3Cell(a, 5)
c2 = H3Cell(b, 5)
GlobalGrids.haversine(c1, c2) # distance between centroids