geoplotlib
geoplotlib copied to clipboard
lon
Hi, I try to run this simple code:
import geoplotlib from geoplotlib.utils import read_csv data = read_csv('bus.csv') geoplotlib.dot(data) geoplotlib.show()
but, I got this error: Traceback (most recent call last): File "C:\Anaconda\lib\site-packages\geoplotlib__init__.py", line 31, in _runapp app.start() File "C:\Anaconda\lib\site-packages\geoplotlib\core.py", line 308, in start self.proj.fit(BoundingBox.from_bboxes([l.bbox() for l in self.geoplotlib_config.layers])) File "C:\Anaconda\lib\site-packages\geoplotlib\layers.py", line 159, in bbox return BoundingBox.from_points(lons=self.data['lon'], lats=self.data['lat']) File "C:\Anaconda\lib\site-packages\geoplotlib\utils.py", line 62, in getitem return self.dict[key] KeyError: 'lon'
Hello,
I'm also having the same problem as this one. What was the solution to this problem?
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/geoplotlib/init.py", line 32, in _runapp app.start() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/geoplotlib/core.py", line 364, in start self.proj.fit(BoundingBox.from_bboxes([l.bbox() for l in self.geoplotlib_config.layers]), File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/geoplotlib/layers.py", line 287, in bbox return BoundingBox.from_points(lons=np.hstack([self.data[self.src_lon], self.data[self.dest_lon]]), File "/Users/caitlyngemma/Desktop/cs330-caitlyngemma/Project_Gemma/utils.py", line 62, in getitem return self.dict[key] KeyError: 'Lon'
Hi Andrea,
Yes, that file is from the examples. I have not check this again, but if you know how to fix that issue, would be great. I think to try it soon.
Thanks, Jaime
OK, so I just came across this same issue 19 months later then the above - just dropped off totally open ended - is there a solution for this issue?
Thanks, Harry
The first line of the csv needs text "lon" and "lat" for the column containing longitude and latitude coordinates, respectively.
In the case of @caitlyngemma , whatever is populating src_lon
and dest_lon
needs "Lon" as a header, although I also suspect lats
needs to be given as an argument in from_points(...)
Hello All,
import geoplotlib #from geoplotlib.utils import read_csv import pandas as pd data = pd.read_csv('India_Cities.csv') geoplotlib.dot(data,point_size=3) geoplotlib.show()
You can try this code.
I have downloaded csv India cities database from https://simplemaps.com/ and download it with India_Cities.csv.
In the csv file I have replaced lng column by lon and run. I got following output
.