Great Circle#
Overview#
This section covers great circle functions from NCL:
area_poly_sphere#
NCL’s area_poly_sphere
calculates the area enclosed by an arbitrary polygon on the sphere
Important Note
Coordinates should be within the valid latitude/longitude range (-90° to 90° and -180° to 180°) and be in clockwise orderDue to the shape of the Earth, the radius varies, but can be assumed to be a unit sphere with a radius of 6370997 m (based on the Clarke 1866 Authalic Sphere[1] model)
Grab and Go#
from pyproj import Geod
# Points in clockise order: Boulder, Boston, Houston
latitudes = [40.0150, 42.3601, 29.5518] # degrees
longitudes = [-105.2705, -71.0589, -95.0982] # degrees
geod = Geod(ellps="sphere") # radius = 6370997 m
poly_area_m, _ = geod.polygon_area_perimeter(longitudes, latitudes)
poly_area_km2 = abs(poly_area_m) * 1e-6
poly_area_km2
1940855.984630871
css2c#
NCL’s css2c
converts spherical (latitude/longitude) coordinates to Cartesian coordinates on a unit sphere
Grab and Go#
from astropy.coordinates.representation import UnitSphericalRepresentation
from astropy import units
lat = 40.0150
lon = -105.2705
spherical_coords = UnitSphericalRepresentation(lat=lat * units.deg, lon=lon * units.deg)
cart_coords = spherical_coords.to_cartesian()
print(f"X = {cart_coords.x.value}")
print(f"Y = {cart_coords.y.value}")
print(f"Z = {cart_coords.z.value}")
X = -0.20171369272651396
Y = -0.7388354627678497
Z = 0.6429881376224998