|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Analytics Feeds\n", |
| 8 | + "\n", |
| 9 | + "This notebook maintains a list of analytics feeds used in this repository." |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "code", |
| 14 | + "execution_count": 1, |
| 15 | + "metadata": {}, |
| 16 | + "outputs": [], |
| 17 | + "source": [ |
| 18 | + "subscriptions = [\n", |
| 19 | + " {\n", |
| 20 | + " 'id': '9db92275-1d89-4d3b-a0b6-68abd2e94142',\n", |
| 21 | + " 'used_by': ['analytics/02_fetching_feed_results']\n", |
| 22 | + " },\n", |
| 23 | + " {\n", |
| 24 | + " 'id': 'cda3398b-1283-4ad9-87a6-e25796b5ca80',\n", |
| 25 | + " 'used_by': ['analytics/03_visualizing_raster_results']\n", |
| 26 | + " },\n", |
| 27 | + " {\n", |
| 28 | + " 'id': '02c4f912-090f-45aa-a18b-ac4a55e4b9ba',\n", |
| 29 | + " 'used_by': ['analytics-snippets/building_footprints_as_vector']\n", |
| 30 | + " },\n", |
| 31 | + " {\n", |
| 32 | + " 'id': 'f184516c-b948-406f-b257-deaa66c3f38a',\n", |
| 33 | + " 'used_by': ['analytics-snippets/roads_as_vector']\n", |
| 34 | + " },\n", |
| 35 | + "]" |
| 36 | + ] |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "markdown", |
| 40 | + "metadata": {}, |
| 41 | + "source": [ |
| 42 | + "## Get feeds from subscription ids" |
| 43 | + ] |
| 44 | + }, |
| 45 | + { |
| 46 | + "cell_type": "code", |
| 47 | + "execution_count": 2, |
| 48 | + "metadata": {}, |
| 49 | + "outputs": [], |
| 50 | + "source": [ |
| 51 | + "from pprint import pprint\n", |
| 52 | + "import os\n", |
| 53 | + "\n", |
| 54 | + "from planet import api" |
| 55 | + ] |
| 56 | + }, |
| 57 | + { |
| 58 | + "cell_type": "code", |
| 59 | + "execution_count": 3, |
| 60 | + "metadata": {}, |
| 61 | + "outputs": [], |
| 62 | + "source": [ |
| 63 | + "# if your Planet API Key is not set as an environment variable, you can paste it below\n", |
| 64 | + "API_KEY = os.environ.get('PL_API_KEY', 'PASTE_YOUR_KEY_HERE')\n", |
| 65 | + "\n", |
| 66 | + "analytics_client = api.ClientV1(api_key=API_KEY)" |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "code", |
| 71 | + "execution_count": 4, |
| 72 | + "metadata": {}, |
| 73 | + "outputs": [ |
| 74 | + { |
| 75 | + "name": "stdout", |
| 76 | + "output_type": "stream", |
| 77 | + "text": [ |
| 78 | + "['Port of Oakland, USA', 'Hefei, China', 'Sazgin, Turkey', 'Kirazli, Turkey']\n", |
| 79 | + "['1b4c9ee2-699b-4621-bb4f-934eda8090b5', '36d9d1b0-dcd4-40bc-b411-5eb8e06062a2', 'b442c53b-fc72-4bee-bab4-0b7aa318ccd9', '36d9d1b0-dcd4-40bc-b411-5eb8e06062a2']\n", |
| 80 | + "['Ship Detections', 'Roads (v7)', 'Buildings (v7)', 'Roads (v7)']\n" |
| 81 | + ] |
| 82 | + } |
| 83 | + ], |
| 84 | + "source": [ |
| 85 | + "def get_sub_info(subscription_id):\n", |
| 86 | + " return analytics_client.get_subscription_info(subscription_id).get()\n", |
| 87 | + "\n", |
| 88 | + "def get_sub_title(subscription_id):\n", |
| 89 | + " return get_sub_info(subscription_id)['title']\n", |
| 90 | + "\n", |
| 91 | + "def get_feed_id(subscription_id):\n", |
| 92 | + " return get_sub_info(subscription_id)['feedID']\n", |
| 93 | + "\n", |
| 94 | + "def get_feed_info(feed_id):\n", |
| 95 | + " return analytics_client.get_feed_info(feed_id).get()\n", |
| 96 | + "\n", |
| 97 | + "def get_feed_title(feed_id):\n", |
| 98 | + " return get_feed_info(feed_id)['title']\n", |
| 99 | + " \n", |
| 100 | + "\n", |
| 101 | + "titles = [get_sub_title(s['id']) for s in subscriptions]\n", |
| 102 | + "print(titles)\n", |
| 103 | + "\n", |
| 104 | + "feed_ids = [get_feed_id(s['id']) for s in subscriptions]\n", |
| 105 | + "print(feed_ids)\n", |
| 106 | + "\n", |
| 107 | + "feed_titles = [get_feed_title(fid) for fid in feed_ids]\n", |
| 108 | + "print(feed_titles)" |
| 109 | + ] |
| 110 | + } |
| 111 | + ], |
| 112 | + "metadata": { |
| 113 | + "kernelspec": { |
| 114 | + "display_name": "Python 3", |
| 115 | + "language": "python", |
| 116 | + "name": "python3" |
| 117 | + }, |
| 118 | + "language_info": { |
| 119 | + "codemirror_mode": { |
| 120 | + "name": "ipython", |
| 121 | + "version": 3 |
| 122 | + }, |
| 123 | + "file_extension": ".py", |
| 124 | + "mimetype": "text/x-python", |
| 125 | + "name": "python", |
| 126 | + "nbconvert_exporter": "python", |
| 127 | + "pygments_lexer": "ipython3", |
| 128 | + "version": "3.7.6" |
| 129 | + } |
| 130 | + }, |
| 131 | + "nbformat": 4, |
| 132 | + "nbformat_minor": 4 |
| 133 | +} |
0 commit comments