Hello All,
I only have 2 years of experience with Python and only a few weeks of playing around with Geoplotlib. So, I'm no expert.
I'm receiving a few exceptions when feeding a script-generated dictionary ultimately into the geoplotlib.plot() function. Utilizing the exact script sequence, but with a hand-written dictionary, ultimately a map is generated. After a good deal of experimentation, the crucial difference between the two dictionaries appears to be that one character space between the colon after the 'key' and the start of a list containing 'values' is present in the script-generated dictionary.
ex:
hand-written - {'key':[value]}
script-generated dictionary - {'key': [value]} #note one character space between ':' and '['
Here's a list of what appears to be the necessary modules loaded in my Python v3.6 installation:
...
numpy 1.14.3
pandas 0.22.0
geoplotlib 0.3.2
matplotlib 3.0.2
pyglet 1.3.2
scipy 1.1.0
pyshp 1.2.12
And an example of the script that runs fine in one case, ie produces a map, as well as the variation that produces the exceptions and no map. Note: Both dictionaries take the name 'dict' after their declaration statements below when ran separately through the rest of the script. Here, implying their renaming was done just to reduce redundancy in the post.
<
...
import numpy as np
import pandas as pd
import geoplotlib
import matplotlib
from geoplotlib.utils import DataAccessObject
import pyglet
import scipy
...
generated_dict = {'lat': [37.7749, 51.5074], 'lon': [-122.4194, 0.1278]} # generated via extraction from a source
static_dict = {'lat':[37.7749, 51.5074], 'lon':[-122.4194, 0.1278]} # typed by hand
print(type(dict)) #output: <class 'dict'>
print(type(dict['lat'][0])) #output: <class 'float'>
df = pd.DataFrame(dict) # characteristics as expected
dao = DataAccessObject(df) # no exceptions
geoplotlib.dot(dao) # no exceptions
geoplotlib.show()
# static_dict results in producing map as expected. No exceptions
# generated_dict throws exception at his step. No map generated
Lastly, the exceptions produced:
Console: Exceptions
C:...Python\Python36\lib\site-packages\geoplotlib\core.py:753:
RuntimeWarning: invalid value encountered in log ytile = (1.0 - np.log(np.tan(lat_rad) + (1 / np.cos(lat_rad))) / math.pi) / 2.0 * n
File "C:...Python\Python36\lib\site-packages\geoplotlib\core.py", line 365, in start
force_zoom=self.geoplotlib_config.requested_zoom)
File "C:...Python\Python36\lib\site-packages\geoplotlib\core.py", line 677, in fit
west_tile, north_tile = self.deg2num(bbox.north, bbox.west, self.zoom)
File "C:...Python\Python36\lib\site-packages\geoplotlib\core.py", line 689, in deg2num
ytile = (1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n ValueError: math domain error
Any help would be greatly appreciated, how do I avoid generating exceptions when feeding a generated dictionary from my scripts into the rest of the processing steps leading to a map being generated? Thanks.