{ "metadata": { "kernelspec": { "name": "python", "display_name": "Pyolite", "language": "python" }, "language_info": { "codemirror_mode": { "name": "python", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8" } }, "nbformat_minor": 4, "nbformat": 4, "cells": [ { "cell_type": "code", "source": "import os\nimport io\nimport json\nfrom urllib.request import urlopen\nfrom datetime import datetime\n\nimport numpy as np\nimport pandas as pd\n\nfrom js import fetch\n\nimport piplite\nawait piplite.install(\"folium\")\n\nimport folium", "metadata": { "trusted": true }, "execution_count": 11, "outputs": [] }, { "cell_type": "code", "source": "URL = \"https://raw.githubusercontent.com/edgecollective/dog-compass/main/tracker/tracker_v_0.2/firmware/arduino/analysis/output.txt\"\nresp = await fetch(URL)\ntext = io.BytesIO((await resp.arrayBuffer()).to_py())\ndata = pd.read_csv(text,header=None,names=['rlat','rlon','blat','blon','dist','rssi','bearing'])", "metadata": { "trusted": true }, "execution_count": 21, "outputs": [] }, { "cell_type": "code", "source": "data", "metadata": { "trusted": true }, "execution_count": 22, "outputs": [ { "execution_count": 22, "output_type": "execute_result", "data": { "text/plain": " rlat rlon blat blon dist rssi bearing\n0 42.412018 -71.297905 42.411846 -71.297539 117.60 -100 302.650\n1 42.412014 -71.297905 42.411846 -71.297539 116.84 -99 302.138\n2 42.412014 -71.297905 42.411846 -71.297539 116.10 -99 302.138\n3 42.412010 -71.297905 42.411846 -71.297539 116.10 -100 301.495\n4 42.412006 -71.297913 42.411842 -71.297539 115.38 -99 300.258\n.. ... ... ... ... ... ... ...\n216 42.411873 -71.297844 42.411896 -71.297729 30.95 -98 254.335\n217 42.411877 -71.297852 42.411896 -71.297737 31.94 -89 255.398\n218 42.411877 -71.297852 42.411877 -71.297707 31.60 -101 270.292\n219 42.411880 -71.297859 42.411877 -71.297676 39.05 -100 273.065\n220 42.411880 -71.297859 42.411880 -71.297661 49.34 -101 269.947\n\n[221 rows x 7 columns]", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
rlatrlonblatblondistrssibearing
042.412018-71.29790542.411846-71.297539117.60-100302.650
142.412014-71.29790542.411846-71.297539116.84-99302.138
242.412014-71.29790542.411846-71.297539116.10-99302.138
342.412010-71.29790542.411846-71.297539116.10-100301.495
442.412006-71.29791342.411842-71.297539115.38-99300.258
........................
21642.411873-71.29784442.411896-71.29772930.95-98254.335
21742.411877-71.29785242.411896-71.29773731.94-89255.398
21842.411877-71.29785242.411877-71.29770731.60-101270.292
21942.411880-71.29785942.411877-71.29767639.05-100273.065
22042.411880-71.29785942.411880-71.29766149.34-101269.947
\n

221 rows × 7 columns

\n
" }, "metadata": {} } ] }, { "cell_type": "code", "source": "", "metadata": { "trusted": true }, "execution_count": 40, "outputs": [] }, { "cell_type": "markdown", "source": "# Folium", "metadata": {} }, { "cell_type": "code", "source": "m = folium.Map(location=[42.41184373664864, -71.298052279043], zoom_start=20)\n", "metadata": { "trusted": true }, "execution_count": 61, "outputs": [] }, { "cell_type": "code", "source": "base_pos=data[[\"blat\",\"blon\",\"rssi\"]]\nfor i in range(0,remote_pos.shape[0]):\n lat = base_pos.iloc[i][0]\n lon = base_pos.iloc[i][1]\n rssi = base_pos.iloc[i][2]\n c=\"red\"\n if(rssi>-100):\n c=\"yellow\"\n if(rssi>-90):\n c=\"green\"\n loc1=[lat,lon]\n folium.Circle(\n radius=1,\n location=loc1,\n popup=\"The Waterfront\",\n color=c,\n fill=False,\n ).add_to(m)\n \nm", "metadata": { "trusted": true }, "execution_count": 62, "outputs": [ { "execution_count": 62, "output_type": "execute_result", "data": { "text/plain": "", "text/html": "
Make this Notebook Trusted to load map: File -> Trust Notebook
" }, "metadata": {} } ] }, { "cell_type": "code", "source": "", "metadata": {}, "execution_count": null, "outputs": [] } ] }