{ "cells": [ { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2020-09-01T02:58:28.765090Z", "start_time": "2020-09-01T02:58:28.761362Z" } }, "source": [ "(content:plotting_maps)=\n", "# Plotting Maps\n", "\n", "In this notebook, we will finally plot some visualizations based on [the post-processed collection previously created](content:post_process_collection). For that, we will use the python package `folium` (please install it with `pip install folium`)." ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "ExecuteTime": { "end_time": "2021-02-24T11:36:00.719523Z", "start_time": "2021-02-24T11:36:00.714696Z" } }, "outputs": [], "source": [ "import folium\n", "import pandas as pd\n", "import numpy as np\n", "import base64\n", "import io\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This simple map that we are going to plot will need two files:\n", "1. [The post-processed collection (processed_top5_cities.csv)](content:post_process_collection)\n", "2. The Geojson/Shapefiles/KML/Lat-long for locations. This information was included in the [original data (worldcities_fb_keys.csv)](content:json_creation), but could also be obtained by querying Facebook for [KMLs](content:listing_all_cities_states_in_a_country_region) or by other Websites, such as [GADM](https://gadm.org/data.html)." ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "ExecuteTime": { "end_time": "2021-02-24T11:36:18.021530Z", "start_time": "2021-02-24T11:36:17.989150Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " | Key | \n", "Name | \n", "Region | \n", "FullLocation | \n", "both_18-40_2G | \n", "both_18-40_3G | \n", "both_18-40_4G | \n", "both_18-40_AllDevices | \n", "both_18-40_Wifi | \n", "both_18-_2G | \n", "... | \n", "population | \n", "id | \n", "fb_query | \n", "name | \n", "key | \n", "region | \n", "region_id | \n", "country_name | \n", "country_code | \n", "type | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "2880782 | \n", "Minato-ku | \n", "Tokyo | \n", "Minato-ku, Tokyo, JP | \n", "1000 | \n", "1000 | \n", "8400 | \n", "64000 | \n", "34000 | \n", "1000 | \n", "... | \n", "35676000.0 | \n", "1392685764 | \n", "Tokyo | \n", "Minato-ku | \n", "2880782 | \n", "Tokyo | \n", "1922 | \n", "Japan | \n", "JP | \n", "city | \n", "
1 | \n", "2490299 | \n", "New York | \n", "New York | \n", "New York, New York, US | \n", "1000 | \n", "4900 | \n", "520000 | \n", "3300000 | \n", "1600000 | \n", "1000 | \n", "... | \n", "19354922.0 | \n", "1840034016 | \n", "New York | \n", "New York | \n", "2490299 | \n", "New York | \n", "3875 | \n", "United States | \n", "US | \n", "city | \n", "
2 | \n", "2673660 | \n", "Mexico City | \n", "Distrito Federal | \n", "Mexico City, Distrito Federal, MX | \n", "1200 | \n", "160000 | \n", "1000000 | \n", "7600000 | \n", "4800000 | \n", "1700 | \n", "... | \n", "19028000.0 | \n", "1484247881 | \n", "Mexico City | \n", "Mexico City | \n", "2673660 | \n", "Distrito Federal | \n", "2513 | \n", "Mexico | \n", "MX | \n", "city | \n", "
3 | \n", "1035921 | \n", "Mumbai | \n", "Maharashtra | \n", "Mumbai, Maharashtra, IN | \n", "11000 | \n", "46000 | \n", "5300000 | \n", "9000000 | \n", "1700000 | \n", "14000 | \n", "... | \n", "18978000.0 | \n", "1356226629 | \n", "Mumbai | \n", "Mumbai | \n", "1035921 | \n", "Maharashtra | \n", "1735 | \n", "India | \n", "IN | \n", "city | \n", "
4 | \n", "269969 | \n", "São Paulo | \n", "São Paulo (state) | \n", "São Paulo, São Paulo (state), BR | \n", "1000 | \n", "45000 | \n", "510000 | \n", "5800000 | \n", "3700000 | \n", "2000 | \n", "... | \n", "18845000.0 | \n", "1076532519 | \n", "São Paulo | \n", "São Paulo | \n", "269969 | \n", "São Paulo (state) | \n", "460 | \n", "Brazil | \n", "BR | \n", "city | \n", "
5 rows × 83 columns
\n", "