Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing longitude values when they cross +/-180 #1

Open
aivanni opened this issue Aug 24, 2017 · 2 comments
Open

Fixing longitude values when they cross +/-180 #1

aivanni opened this issue Aug 24, 2017 · 2 comments

Comments

@aivanni
Copy link

aivanni commented Aug 24, 2017

The function convert_to_latlon gives wrong longitude values that can be above 180 or below -180 degrees when the reference longitude is close to +/-180. This should fix it:

def convert_to_latlon(y, x, latitude, longitude):

    pi = 3.14159265359

    r_earth = 6371000

   lat_diff = (y / r_earth) * (180 / pi)
   lon_diff = (x / r_earth) * (180 / pi) / math.cos(latitude * pi/180)

   final_lat = latitude+lat_diff
   final_lon = longitude+lon_diff

   final_lon = final_lon - 360 if final_lon > 180 else final_lon
   final_lon = 360 + final_lon if final_lon < -180 else final_lon

   return (final_lat, final_lon)
@aivanni
Copy link
Author

aivanni commented Oct 6, 2017

is there anybody alive in this repo? @ashwin711

@winash12
Copy link

winash12 commented Sep 7, 2018

I sent him an email as well. No response. I guess this repo is not alive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants