Latitude (ϕ) lines run east-west and are parallel to each other but measure north-north. So if you go north, latitude values increase. Finally, latitude values (Y-values) range between -90 and +90 degrees.
Longitude (λ) lines run north-south and measure east-west. They converge at the poles. And its X-coordinates are between -180 and +180 degrees.
frommathimportradians,sin,cos,sqrt,atan2,degreesdefhaversine(coord1,coord2):# Coordinates: (lat, lon)R=6371.0# Earth radius in kilometerslat1,lon1=map(radians,coord1)lat2,lon2=map(radians,coord2)dlat=lat2-lat1dlon=lon2-lon1a=sin(dlat/2)**2+cos(lat1)*cos(lat2)*sin(dlon/2)**2c=2*atan2(sqrt(a),sqrt(1-a))returnR*cdefbearing_between_points(lat1,lon1,lat2,lon2):# Convert to radianslat1,lon1,lat2,lon2=map(radians,[lat1,lon1,lat2,lon2])dlon=lon2-lon1x=sin(dlon)*cos(lat2)y=cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(dlon)initial_bearing=atan2(x,y)# Convert from radians to degrees and normalize 0-360bearing=(degrees(initial_bearing)+360)%360returnbearing# Exampleorigin=(32.0853,34.7818)# Tel Avivtarget=(32.085300,34.787107)# next point ~500m eastprint(f"Distance: {haversine(origin,target):.2f} km")print(f"Bearing (from north cw): {bearing_between_points(32.0853,34.7818,32.085300,34.787107):.2f}°")
Datum
A datum in geodesy and mapping is a reference framework that defines the shape, size, and position of the coordinate system used to describe locations on Earth.
WGS84 (World Geodetic System 1984) is one of the most important modern datums, is use by GPS navigation system.