Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Charts and graphs are definitely a step up from viewing data in a spreadsheet. Let's take a look at how Bokeh can take visualizations even further.
Country coordinate URL:
https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json
Code for parsing JSON Data:
def get_coordinates(features):
depth = lambda L: isinstance(L, list) and max(map(depth, L))+1
country_id = []
longitudes = []
latitudes = []
for feature in json_data['features']:
coordinates = feature['geometry']['coordinates']
number_dimensions = depth(coordinates)
# one border
if number_dimensions == 3:
country_id.append(feature['id'])
points = np.array(coordinates[0], 'f')
longitudes.append(points[:, 0])
latitudes.append(points[:, 1])
# several borders
else:
for shape in coordinates:
country_id.append(feature['id'])
points = np.array(shape[0], 'f')
longitudes.append(points[:, 0])
latitudes.append(points[:, 1])
return country_id, longitudes, latitudes
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up