'Get the latitude and longitude of point after being moved
I have some point A with latitude and longitude (x, y) and i want to know the latitude and longitude of a new point (B) which is the point A after moving it 75km to the right with an angle theta (compared with the equator). Please anyone has an idea i'll appreciate it.
A(x, y) ------------75km---------> B(x', y')
from math import sqrt,atan,pi
import folium
import pyproj
geod = pyproj.Geod(ellps='WGS84')
width = 75000. # m
height = 75000. # m
rect_diag = sqrt( width**2 + height**2 )
center_lon = -0.5493
center_lat = 35.7108
azimuth1 = atan(width/height)
azimuth2 = atan(-width/height)
azimuth3 = atan(width/height)+pi # first point + 180 degrees
azimuth4 = atan(-width/height)+pi # second point + 180 degrees
pt1_lon, pt1_lat, _ = geod.fwd(center_lon, center_lat, azimuth1*180/pi, rect_diag)
pt2_lon, pt2_lat, _ = geod.fwd(center_lon, center_lat, azimuth2*180/pi, rect_diag)
pt3_lon, pt3_lat, _ = geod.fwd(center_lon, center_lat, azimuth3*180/pi, rect_diag)
pt4_lon, pt4_lat, _ = geod.fwd(center_lon, center_lat, azimuth4*180/pi, rect_diag)
wkt_point = 'POINT (%.6f %.6f)' % (center_lon, center_lat)
wkt_poly = 'POLYGON (( %.6f %.6f, %.6f %.6f, %.6f %.6f, %.6f %.6f, %.6f %.6f ))' % (pt1_lon, pt1_lat, pt2_lon, pt2_lat, pt3_lon, pt3_lat, pt4_lon, pt4_lat, pt1_lon, pt1_lat)
print(wkt_point)
print(wkt_poly)
m = folium.Map(location = (35.697070, -0.630799), tiles="Stamen Terrain", zoom_start=6)
folium.Marker(
[35.697070, -0.630799], popup="<i>Mt. Hood Meadows</i>", tooltip='oran'
).add_to(m)
folium.Rectangle([(pt1_lat, pt1_lon), (pt3_lat, pt3_lon)], weight=2, color="red").add_to(m)
m.save('sat.html')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
