{ "cells": [ { "cell_type": "markdown", "id": "0f09e1c5", "metadata": {}, "source": [ "# Speedtest Data from Ookla\n", "\n", "This example will use data collected from Ookla's Speed Test application and [shared publicly in the AWS Open Data Registry](https://registry.opendata.aws/speedtest-global-performance/). From the AWS page:\n", "\n", "> Global fixed broadband and mobile (cellular) network performance, allocated to zoom level 16 web mercator tiles (approximately 610.8 meters by 610.8 meters at the equator). Data is provided in both Shapefile format as well as Apache Parquet with geometries represented in Well Known Text (WKT) projected in EPSG:4326. Download speed, upload speed, and latency are collected via the Speedtest by Ookla applications for Android and iOS and averaged for each tile." ] }, { "cell_type": "markdown", "id": "7dd1dfef-3756-49d9-9480-9a4cdba22345", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": 1, "id": "d1678764", "metadata": {}, "outputs": [], "source": [ "import geopandas as gpd\n", "import numpy as np\n", "import pandas as pd\n", "import shapely\n", "from palettable.colorbrewer.diverging import BrBG_10\n", "\n", "from lonboard import ScatterplotLayer, viz\n", "from lonboard.colormap import apply_continuous_cmap" ] }, { "cell_type": "markdown", "id": "c747d8b9-94b9-421a-967a-8350bf72de9a", "metadata": {}, "source": [ "The URL for a single data file for mobile network speeds in the first quarter of 2019." ] }, { "cell_type": "code", "execution_count": 2, "id": "34ac8eae", "metadata": {}, "outputs": [], "source": [ "url = \"https://ookla-open-data.s3.us-west-2.amazonaws.com/parquet/performance/type=mobile/year=2019/quarter=1/2019-01-01_performance_mobile_tiles.parquet\"" ] }, { "cell_type": "markdown", "id": "5991ef2c-5db0-4110-b6a1-b33fcbddad0d", "metadata": {}, "source": [ "We can fetch two columns from this data file directly from AWS. This `pd.read_parquet` command will perform a network request for the data file, so it may take a while on a slow network connection." ] }, { "cell_type": "code", "execution_count": 3, "id": "8e7bc021", "metadata": {}, "outputs": [], "source": [ "# avg_d_kbps is the average download speed for that data point in kilobits per second\n", "# tile is the WKT string representing a given zoom-16 Web Mercator tile\n", "columns = [\"avg_d_kbps\", \"tile\"]" ] }, { "cell_type": "code", "execution_count": 4, "id": "f0be9f56", "metadata": {}, "outputs": [], "source": [ "df = pd.read_parquet(url, columns=columns)" ] }, { "cell_type": "markdown", "id": "5852aa94-2d18-4a1b-b379-be19682d57eb", "metadata": {}, "source": [ "We can take a quick look at this data:" ] }, { "cell_type": "code", "execution_count": 5, "id": "4b27e9a4", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | avg_d_kbps | \n", "tile | \n", "
|---|---|---|
| 0 | \n", "5983 | \n", "POLYGON((-160.021362304688 70.6381267305321, -... | \n", "
| 1 | \n", "3748 | \n", "POLYGON((-160.043334960938 70.6344840663086, -... | \n", "
| 2 | \n", "3364 | \n", "POLYGON((-160.043334960938 70.6326624870732, -... | \n", "
| 3 | \n", "2381 | \n", "POLYGON((-160.037841796875 70.6344840663086, -... | \n", "
| 4 | \n", "3047 | \n", "POLYGON((-160.037841796875 70.6326624870732, -... | \n", "
| \n", " | avg_d_kbps | \n", "geometry | \n", "
|---|---|---|
| 383429 | \n", "13570 | \n", "POINT (-2.94159 58.99673) | \n", "
| 383430 | \n", "18108 | \n", "POINT (-3.29865 58.96276) | \n", "
| 383431 | \n", "5569 | \n", "POINT (-3.29315 58.97125) | \n", "
| 383432 | \n", "9349 | \n", "POINT (-3.29315 58.96842) | \n", "
| 383433 | \n", "11216 | \n", "POINT (-3.23273 58.98541) | \n", "
| ... | \n", "... | \n", "... | \n", "
| 1840929 | \n", "104723 | \n", "POINT (25.38666 35.09519) | \n", "
| 1840930 | \n", "62540 | \n", "POINT (25.44708 35.04124) | \n", "
| 1840931 | \n", "88068 | \n", "POINT (25.47455 35.04124) | \n", "
| 1840938 | \n", "38255 | \n", "POINT (25.38116 35.00075) | \n", "
| 1840939 | \n", "91750 | \n", "POINT (25.45807 34.99175) | \n", "
807221 rows × 2 columns
\n", "