方位角,画一条线
Azimuth, Draw a line
我正在尝试使用 folium 在地图上绘制给定坐标的方位角。我是 python 的新手,我迷路了。
objective 是获取一个坐标和一个度数,然后绘制到地图上。
我正在尝试使用 folium,但它不需要是 folium。
import folium
# criar o objeto do mapa
m = folium.Map(location=[37.0431575, -7.8449655], zoom_start=14)
# Texto que vai aparecer no marcador
tootip = "Célula em Olhão"
folium.CircleMarker(
location=[37.040893, -7.83197],
radius=4,
popup="célula",
).add_to(m)
# posicao = folium.RegularPolygonMarker(
# location=[37.040893, -7.83197],
# fill_color='blue',
# number_of_sides=3,
# radius=10,
# rotation=45).add_to(m)
# I TRIED WITH A TRIANGULE BUT I COULDN'T UNDERSTANT WICH PART WAS
# POINTING AT THE DESIRED DIRECTION
m.save("mapa.html")
如何画一条从圆度 45º 开始的线?线的大小并不重要,它只需要可见即可。
谢谢你
是这样的吗?
借助 math
和一些技巧
import folium
import math
# criar o objeto do mapa
m = folium.Map(location=[37.0431575, -7.8449655], zoom_start=14)
# Texto que vai aparecer no marcador
tootip = "Célula em Olhão"
origin_point = [37.040893, -7.83197]
folium.CircleMarker(
location=origin_point,
radius=4,
popup="célula",
).add_to(m)
length = .01
angle = 45
end_lat = origin_point[0] + length * math.sin(math.radians(angle))
end_lon = origin_point[1] + length * math.cos(math.radians(angle))
folium.PolyLine([origin_point, [end_lat, end_lon]]).add_to(m)
m
我正在尝试使用 folium 在地图上绘制给定坐标的方位角。我是 python 的新手,我迷路了。 objective 是获取一个坐标和一个度数,然后绘制到地图上。 我正在尝试使用 folium,但它不需要是 folium。
import folium
# criar o objeto do mapa
m = folium.Map(location=[37.0431575, -7.8449655], zoom_start=14)
# Texto que vai aparecer no marcador
tootip = "Célula em Olhão"
folium.CircleMarker(
location=[37.040893, -7.83197],
radius=4,
popup="célula",
).add_to(m)
# posicao = folium.RegularPolygonMarker(
# location=[37.040893, -7.83197],
# fill_color='blue',
# number_of_sides=3,
# radius=10,
# rotation=45).add_to(m)
# I TRIED WITH A TRIANGULE BUT I COULDN'T UNDERSTANT WICH PART WAS
# POINTING AT THE DESIRED DIRECTION
m.save("mapa.html")
如何画一条从圆度 45º 开始的线?线的大小并不重要,它只需要可见即可。 谢谢你
是这样的吗?
借助 math
和一些技巧
import folium
import math
# criar o objeto do mapa
m = folium.Map(location=[37.0431575, -7.8449655], zoom_start=14)
# Texto que vai aparecer no marcador
tootip = "Célula em Olhão"
origin_point = [37.040893, -7.83197]
folium.CircleMarker(
location=origin_point,
radius=4,
popup="célula",
).add_to(m)
length = .01
angle = 45
end_lat = origin_point[0] + length * math.sin(math.radians(angle))
end_lon = origin_point[1] + length * math.cos(math.radians(angle))
folium.PolyLine([origin_point, [end_lat, end_lon]]).add_to(m)
m