Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
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 up-
PLUS
alymasud
Courses Plus Student 3,239 Points0 Answers
-
James Thomas
Python Web Development Techdegree Student 279 Points1 Answer
View all discussions for this video
Related 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