{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas as pd\n", "import folium\n", "from folium.plugins import TimestampedGeoJson\n", "import json" ] }, { "cell_type": "code", "execution_count": 2, "outputs": [ { "data": { "text/plain": "", "text/html": "
Make this Notebook Trusted to load map: File -> Trust Notebook
" }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv('data/Smart Trash Containers.csv')\n", "\n", "containers_map = folium.Map(location=[40.4406, -79.9959], zoom_start=12)\n", "records = df[['x', 'y']].to_records()\n", "\n", "containers_map = containers_map = folium.Map(location=[40.4406, -79.9959], zoom_start=11)\n", "# Add the markers to the map...\n", "for record in records:\n", " folium.Marker(location=[record[2], record[1]],\n", " icon=folium.Icon(color='green',\n", " icon_color='white',\n", " icon='trash-o',\n", " prefix='fa',\n", " )\n", " ).add_to(containers_map)\n", "\n", "containers_map" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": 3, "outputs": [], "source": [ "with open('data/smart_trash_containers.geojson') as j:\n", " data = json.load(j)" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": 4, "outputs": [], "source": [ "for i in range(len(data['features'])):\n", " data['features'][i]['properties']['times'] = [data['features'][i]['properties']['assignment_date'][:19]]" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": 5, "outputs": [ { "data": { "text/plain": "", "text/html": "
Make this Notebook Trusted to load map: File -> Trust Notebook
" }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "containers_map = folium.Map(location=[40.4406, -79.9959], zoom_start=12)\n", "TimestampedGeoJson(data, transition_time=20).add_to(containers_map)\n", "containers_map" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": 5, "outputs": [], "source": [], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }