wingchen / citipy Goto Github PK
View Code? Open in Web Editor NEWLook for nearest city with geo coordinates.
License: MIT License
Look for nearest city with geo coordinates.
License: MIT License
When you click the Maxmind URL, it returns:
Getting an error when I try to use the command
from citipy import citipy
Already installed citipy using pip comamnd
12 # Incorporated citipy to determine city based on latitude and longitude
---> 13 from citipy import citipy
14
15
C:\Users\213062180\AppData\Local\Continuum\anaconda2\lib\site-packages\citipy\citipy.py in ()
24
25 # discard the headers
---> 26 cities.next()
27
28 # populate geo points into kdtree
AttributeError: '_csv.reader' object has no attribute 'next'
I had latitude and longitude values that placed me right next to Manila, Philippines, but for some reason, citipy would return Santa Monica as the nearest city. Even though there is a Santa Monica in the Philippines, it is some 100+ miles away from Manila.
If you want to look into the citipy error I encountered, you can try to recreate it yourself:
lat = 15.325736570808928
lng = 120.73129576518153
print(f"{citipy.nearest_city(lat, lng).city_name}")
When I run this, it returns santa monica
. Notice that Santa Monica, Philippines is located at approximately (10.12651, 126.04144). Off by about 5 degrees in both latitude and longitude. Citipy does not work as expected here, and I imagine it is due to some flaw in the data set that citipy is based off of. I haven't tested very many other data points and checked, because it's rather time consuming.
I checked the csv, and line 32940 has the following:
ph,santa monica,15.35771,120.72006
This is incorrect, unless google maps' location data cannot be trusted, which is how I verified this. Not sure if you want to make an explicit change to the csv itself considering you probably reload that data every so often, but I wanted to note this error. Perhaps it can be forwarded up the line.
Great Library! Very handy. Worked well for a Python 2.7 project.
Unfortunately, not so well with a Python 3.5 project. Import doesn't seem to work. I'll look at your code to see if this a quick fix
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-b49a8be8dcc2> in <module>()
9
10 # Incorporated citipy to determine city based on latitude and longitude
---> 11 from citipy import citipy
12
13 # Output File (CSV)
C:\Users\Ahmed\Anaconda3\envs\PythonData\lib\site-packages\citipy\citipy.py in <module>()
24
25 # discrad the headers
---> 26 cities.next()
27
28 # populate geo points into kdtree
AttributeError: '_csv.reader' object has no attribute 'next'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.