-1
  • I have 3 known positions onto a map using X, Y matplotlib using subplots, I need to plot a bearing from one of the towers and place a line onto the map.
  • I am currently using X, Y for start position and arrow/line for the end position. But would like to know how to use a bearing in place of the end of the line instead of x, y. I'm currently looking into Vectors but having no luck.

My code is below any help would be great

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import math


df = pd.read_csv("Book1.csv")
df.head()
tower1x = [51.69557]
tower1y = [-3.34197]
tower2x = [51.69673]
tower2y = [-3.34235]

tower3x = [51.69630]
tower3y = [-3.34090]


BBox = (df.longitude.min(), df.longitude.max(),
        df.latitude.min(), df.latitude.max())
print (BBox)
     
ruh_m = plt.imread('map.png')

fig, ax = plt.subplots(figsize = (12,12))



ax.scatter(tower1x, tower1y, zorder=1, alpha= 0.5, c='red', s=50, label="Tower 1")
ax.scatter(tower2x, tower2y, zorder=1, alpha= 0.5, c='blue', s=50, label="Tower 2")
ax.scatter(tower3x, tower3y, zorder=1, alpha= 0.5, c='green', s=50, label="Tower 3")

ax.annotate("",xy=(51.69557,-3.34197), xytext=**(51.69799, -3.34155)**, textcoords='data',
            arrowprops=dict(arrowstyle="<-", connectionstyle="arc3"),) # point from tower 1 using X,Y

ax.set_title('Plotting Towers in Aberfan')
ax.set_xlim(BBox[0],BBox[1])
ax.set_ylim(BBox[2],BBox[3])
ax.imshow(ruh_m, zorder=0, extent = BBox, aspect= 'equal')


plt.legend()
plt.show()

1 Answers1

0
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import math


df = pd.read_csv("Grids.csv")
df.head()
##
###X and Y Coordinates using www.openstreetmap.org
BBox = (df.longitude.min(), df.longitude.max(),
        df.latitude.min(), df.latitude.max())


#Signal power
s1 = int(input("Enter power from tower 1: "))
s2 = int(input("Enter power from tower 2: "))
s3 = int(input("Enter power from tower 3: "))

#weight of signal
w1 = [s1 / ( s1 + s2 +  s3 )]
w2 = [s2 / ( s1 + s2  + s3 )] 
w3 = [s3 / ( s1 + s2 + s3 )]

#Tower locations 
tower1_lat = np.array ([51.6985630])
tower1_lon = np.array ([-3.3410239])
##
tower2_lat = np.array ([51.6984699])
tower2_lon = np.array ([-3.3400422])
##
tower3_lat = np.array([51.6980743])
tower3_lon = np.array([-3.3406511])

#Your location using the above values
Locaion_Longitude = [tower1_lat * w1 + tower2_lat * w2 + tower3_lat * w3 ]
Locaion_Latitude = [tower1_lon * w1 + tower2_lon * w2 + tower3_lon* w3 ]
print (Locaion_Longitude)
print (Locaion_Latitude)



    
map_fig = plt.imread('map.png')



fig, ax = plt.subplots(dpi=150,figsize = (12,7))



ax.scatter(tower1_lon, tower1_lat, zorder=1, alpha= 0.5, c='red', s=50, label="Tower 1")
ax.scatter(tower2_lon, tower2_lat, zorder=1, alpha= 0.5, c='blue', s=50, label="Tower 2")
ax.scatter(tower3_lon, tower3_lat, zorder=1, alpha= 0.5, c='green', s=50, label="Tower 3")
ax.scatter(Locaion_Longitude, Locaion_Latitude, zorder=1, c='yellow', s=50, label="Your location")


ax.tick_params (axis='y', which='major', labelsize=5)
ax.tick_params (axis='x', which='major', labelsize=5)#axis settings
ax.set_title('Plotting Towers in Aberfan')
ax.set_xlim(BBox[0],BBox[1])
ax.set_ylim(BBox[2],BBox[3])
ax.imshow(map_fig, zorder=0, extent = BBox, aspect= "auto")


mng = plt.get_current_fig_manager() #full screen
mng.window.state("zoomed")

plt.legend()

plt.show()

enter code here