Last active
August 11, 2020 21:20
-
-
Save angeloped/e22a21d75c4f0ac4b64b11b6b7d4074f to your computer and use it in GitHub Desktop.
Geographical City/State prediction. Focc please fix me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
""" | |
Download the data here: https://github.com/angeloped/OSDSint/tree/master/geocodes | |
""" | |
with open("geocities.csv", 'r') as csv_file: | |
csv_globe = [a for a in csv.DictReader(csv_file)] | |
def pos_neg(num1, num2): | |
return (num1 > 0) == (num2 > 0) | |
def nearest(csv_globe, geo_long, geo_lat): | |
i = 0 | |
while i < len(csv_globe): | |
if (float(geo_long) <= float(csv_globe[i-1]["LNG"]) and float(geo_lat) >= float(csv_globe[i-1]["LAT"])) and pos_neg(float(geo_lat), float(csv_globe[i-1]["LAT"])): | |
return csv_globe[i-1] | |
elif (float(geo_long) <= float(csv_globe[i-1]["LNG"]) and float(geo_lat) <= float(csv_globe[i-1]["LAT"])) and pos_neg(float(geo_lat), float(csv_globe[i-1]["LAT"])): | |
return csv_globe[i-1] | |
else: | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment