{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from memair import Memair\n", "# Use Otto the sandbox user's access token or create your own at https://memair.com/temporary_access_token\n", "access_token = '0000000000000000000000000000000000000000000000000000000000000000'\n", "\n", "user = Memair(access_token)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'10000 locations'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "query = '''\n", " {\n", " Locations(\n", " first: 10000\n", " within: \"40.7587,-73.9787,8000\"\n", " from_timestamp: \"2018-05-01\"\n", " order: random\n", " ) {\n", " lat\n", " lon\n", " }\n", " }\n", "\n", "'''\n", "response = user.query(query)\n", "\n", "locations = response['data']['Locations']\n", "f\"{len(locations)} locations\"" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import folium\n", "from folium.plugins import HeatMap\n", "\n", "data = [ [loc['lat'], loc['lon'], 1] for loc in locations ]\n", " \n", "folium_heatmap = folium.Map(location = [40.7587, -73.9787],\n", " zoom_start = 12,\n", " tiles = \"CartoDB positron\")\n", "\n", "HeatMap(data).add_to(folium_heatmap)\n", "folium_heatmap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.0" } }, "nbformat": 4, "nbformat_minor": 2 }