![]() |
Bearing is a significant angle for Geographic Information System (GIS) applications. In this article, we will see how to calculate the compass Bearing using the OSMnx bearing module based on lat-Ion Points. What is Bearing?Bearing represents the clockwise angle in degrees between the north and the geodesic line from (lat1, lon1) to (lat2, lon2). It is used to define navigation commonly in the fields of street network modeling, vehicle navigation, aircraft or marine navigation, or land surveying. Bearings are always measured from the North, in a clockwise direction. Refer to the below diagram: ![]() Bearing measured from North
Syntax of osmnx.bearing.calculate_bearing() Function
Calculate Compass Bearing Using Python OSMnx Bearing ModuleBelow is the step-by-step explanation to calculate compass bearing using OSMnx bearing Module in Python: Step 1: Create GeoDataFrame Using Coordinates and Display MapBefore calculating the bearing, let’s look at the coordinates on the map. below code uses GeoPandas to create a GeoDataFrame from a dictionary of coordinates representing Thiruvananthapuram and Kollam. It then displays the map of these locations.
Output ![]() Plotting the coordinates Step 2: Calculate Bearing Between Two Coordinates Using OSMnx ModuleLet’s calculate the bearing for the given lat-lon points. Below code uses OSMnx to calculate the bearing between two sets of coordinates representing Thiruvananthapuram and Kollam. It computes the bearing using the calculate_bearing() function and returns the result.
Output 316.57324725701557
Bearing
Calculate Bearings for Multiple Coordinate PairsBelow code uses OSMnx and NumPy to compute bearings between Thiruvananthapuram, Kollam, and Pathanamthitta coordinates. It employs calculate_bearing() to determine bearings between Thiruvananthapuram and Kollam, and between Kollam and Pathanamthitta, returning the results.
Output array([316.57324726, 26.63232046]) Here we take two set of coordinates – (Thiruvanathapuram and Kollam), (Kollam and Pathanamthitta) From the output we can conclude, Kollam bears 316.57° from Thiruvananthapuram and Pathanamthitta bears 26.63° from Kollam. |
Reffered: https://www.geeksforgeeks.org
Python |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |