Skip to content

Instantly share code, notes, and snippets.

@rhine3
Created February 22, 2020 19:17
Show Gist options
  • Select an option

  • Save rhine3/389b5eec8371ede200e76aebb8de91b6 to your computer and use it in GitHub Desktop.

Select an option

Save rhine3/389b5eec8371ede200e76aebb8de91b6 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import chaser\n",
"import pandas as pd\n",
"import requests\n",
"import os\n",
"from io import BytesIO"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Parameters"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"begin_month = 3\n",
"end_month = 3\n",
"begin_week = 10\n",
"end_week = 10\n",
"freq_sum_threshold = 0.1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Function definitions"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"def get_hotspots(region = 'CO'):\n",
" html = requests.get(f'https://api.ebird.org/v2/ref/hotspot/{region}').content\n",
" return pd.read_csv(BytesIO(html), names = [\"id\",\"country\",\"subnational1\",\"subnational2\",\"lat\",\"long\",\"name\",\"date\",\"num\"])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def get_freq_table(\n",
" location_id,\n",
" begin_year = 1900,\n",
" end_year = 2020,\n",
" begin_month = 1,\n",
" end_month = 12,\n",
" begin_week = 1,\n",
" end_week = 52\n",
" ):\n",
" \"\"\"\n",
" Get eBird species frequency table for a hotspot\n",
" \n",
" Returns eBird frequency tables for a selection of weeks,\n",
" removing non-species designations (like \"spuhs\" or \"slashes\")\n",
" \n",
" Arguments:\n",
" location_id : str\n",
" the location code of the hotspot, starting with \"L\"\n",
" begin_year : int <= current year\n",
" first year of eBird historical data to calculate frequencies from\n",
" end_year : begin_year <= int <= current year\n",
" final year of eBird historical data to calculate frequencies from\n",
" begin_month : 1 <= int <= 12\n",
" beginning month of the frequency table. Changing this eliminates\n",
" species that are only present before this month, but year-round\n",
" frequencies will be returned unless begin_week and end_week are modified.\n",
" 1 = January, 2 = February, etc.\n",
" end_month : 1 <= int <= 12\n",
" ending month of the frequency table. Changing this eliminates\n",
" species that are only present after this month, but year-round\n",
" frequencies will be returned unless begin_week and end_week are modified.\n",
" 11 = November, 12 = December, etc.\n",
" begin_week : 1 <= int <= 52\n",
" first week of the year to return frequency data from.\n",
" e.g. 1 is the first week of january, 5 is the first week of February\n",
" end_week : begin_week <= int <= 52\n",
" last week of the year to return frequency data from.\n",
" e.g. 4 is the last week of January, 52 is the last week of December\n",
" \n",
" Returns:\n",
" pd.DataFrame\n",
" index: species names\n",
" columns: week indices\n",
" values: percentage of checklists at hotspot during week containing this species\n",
" \n",
" \"\"\"\n",
" \n",
" # Get bar chart table from URL\n",
" url = f\"https://ebird.org/barchartData?byr={begin_year}&eyr={end_year}&bmo={begin_month}&emo={end_month}&r={location_id}&personal=false&fmt=tsv\"\n",
" html = requests.get(url).content\n",
" try:\n",
" # Parse HTML into freqs for each of 52 weeks\n",
" freqs = pd.read_csv(BytesIO(html.split(b'\\n\\n')[7]), sep='\\t', names=['Species', *list(range(1, 53))])\n",
" except:\n",
" return False\n",
" \n",
" \n",
" # Remove intermediate month label rows (no species data)\n",
" #freqs = freqs[~freqs['Species'].isnull()]\n",
" \n",
" # Remove non-species rows (\"sp.\"s, \"(Domestic-type)\"s, \"/\"s)\n",
" freqs = freqs[~freqs['Species'].str.contains('sp.') & ~freqs['Species'].str.contains('/') & ~freqs['Species'].str.contains('\\(')]\n",
"\n",
" # Return only the desired weeks \n",
" freqs.set_index('Species', inplace=True)\n",
" return freqs.iloc[:, begin_week-1:end_week]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"def lat_long_distance_km(\n",
" lat1, \n",
" lon1,\n",
" lat2,\n",
" lon2):\n",
" '''\n",
" Get the distance in km between two locations.\n",
" \n",
" Arguments:\n",
" lat1 : float\n",
" latitude of first location\n",
" lon1: float\n",
" longitude of first location\n",
" lat2 : float\n",
" latitude of second location\n",
" lon1 : float\n",
" longitude of second location\n",
" \n",
" Returns:\n",
" distance in km between first and second location\n",
" '''\n",
" from math import sin, cos, sqrt, atan2, radians\n",
"\n",
" # approximate radius of earth in km\n",
" R = 6373.0\n",
"\n",
" dlon = lon2 - lon1\n",
" dlat = lat2 - lat1\n",
"\n",
" a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2\n",
" c = 2 * atan2(sqrt(a), sqrt(1 - a))\n",
"\n",
" return R * c"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"def get_hotspots_within_distance(\n",
" desired_hotspot,\n",
" hotspots_df,\n",
" max_distance_km,\n",
" in_regions = None, #can speed things up\n",
" in_regions_level = None #e.g. subnational1\n",
"):\n",
" '''\n",
" Given a central hotspot, find all hotspots within certain distance of hotspot.\n",
" \n",
" Arguments:\n",
" desired_hotspot : string\n",
" eBird location code for hotspot, starting with \"L\"\n",
" hotspots_df : pd.DataFrame\n",
" pandas dataframe containing the latitudes and longitudes\n",
" of all relevant hotspots\n",
" max_distance_km : float\n",
" the maximum acceptable distance for a hotspot\n",
" in_regions : list of strings (optional)\n",
" list of eBird region codes to select from, e.g. to \n",
" only return hotspots within a particular state.\n",
" without in_regions, returns all hotspots fitting\n",
" distance criteria in hotspots_df\n",
" in_regions_level : string (optional)\n",
" the eBird level designation of the regions \n",
" provided in `in_regions`. E.g. 'subnational1'\n",
" for US states or Colombian districts, 'subnational2'\n",
" for US counties\n",
" '''\n",
" if in_regions:\n",
" hotspots_df = hotspots_df[hotspots_df[in_regions_level].isin(in_regions)]\n",
" \n",
" lat1 = hotspots_df[hotspots_df['id'] == desired_hotspot].lat\n",
" lon1 = hotspots_df[hotspots_df['id'] == desired_hotspot].long\n",
" \n",
" matching_locs = []\n",
" for iterrow in hotspots_df.iterrows():\n",
" row = iterrow[1]\n",
" lat2 = row.lat\n",
" lon2 = row.long\n",
" if lat_long_distance_km(lat1, lon1, lat2, lon2) < max_distance_km:\n",
" matching_locs.append(row.id)\n",
" \n",
" return hotspots_df[hotspots_df.id.isin(matching_locs)]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"def get_likely_species(\n",
" location,\n",
" begin_month = begin_month,\n",
" end_month = end_month, \n",
" begin_week = begin_week,\n",
" end_week = end_week,\n",
" freq_sum_threshold = freq_sum_threshold,\n",
"):\n",
" '''\n",
" Return the species likely to be found at an eBird location\n",
" \n",
" Arguments:\n",
" location : string\n",
" eBird location code of the location to consider, starting with \"L\"\n",
" freq_sum_threshold : 0 <= float <= 52\n",
" species frequencies are summed across the weeks of the year.\n",
" Each week has a value from 0 to 1.\n",
" only species that meet this threshold will be returned.\n",
" Note that if using 52, the only species that will be returned\n",
" are ones that are present in every week of the year\n",
" \n",
" begin_month : see `get_freq_table`\n",
" end_month : see `get_freq_table`\n",
" begin_week : see `get_freq_table`\n",
" end_week : see `get_freq_table`\n",
" \n",
" Returns:\n",
" set of strings, list of unique species present in any of the given sites\n",
" '''\n",
" \n",
"\n",
" table = get_freq_table(\n",
" location_id = location,\n",
" begin_year = 1900,\n",
" end_year = 2020,\n",
" begin_month = begin_month,\n",
" end_month = end_month, \n",
" begin_week = begin_week,\n",
" end_week = end_week\n",
" )\n",
" \n",
" # Return likely species for location\n",
" return table[table.sum(axis=1) >= freq_sum_threshold].index.tolist()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Let's do it"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>id</th>\n",
" <th>country</th>\n",
" <th>subnational1</th>\n",
" <th>subnational2</th>\n",
" <th>lat</th>\n",
" <th>long</th>\n",
" <th>name</th>\n",
" <th>date</th>\n",
" <th>num</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>L7129862</td>\n",
" <td>CO</td>\n",
" <td>CO-CAS</td>\n",
" <td>NaN</td>\n",
" <td>4.895234</td>\n",
" <td>-71.457996</td>\n",
" <td>AICA Bioparque Wisirare (CO206)</td>\n",
" <td>2019-12-24 10:57</td>\n",
" <td>145.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>L7750589</td>\n",
" <td>CO</td>\n",
" <td>CO-NAR</td>\n",
" <td>NaN</td>\n",
" <td>1.398537</td>\n",
" <td>-77.290474</td>\n",
" <td>Aeropuerto Antonio Nariño</td>\n",
" <td>2019-05-04 14:45</td>\n",
" <td>35.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>L2235118</td>\n",
" <td>CO</td>\n",
" <td>CO-ANT</td>\n",
" <td>NaN</td>\n",
" <td>6.218825</td>\n",
" <td>-75.587328</td>\n",
" <td>Aeropuerto Enrique Olaya Herrera</td>\n",
" <td>2019-12-22 10:00</td>\n",
" <td>40.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>L3800354</td>\n",
" <td>CO</td>\n",
" <td>CO-ATL</td>\n",
" <td>NaN</td>\n",
" <td>10.887591</td>\n",
" <td>-74.777369</td>\n",
" <td>Aeropuerto Ernesto Cortissoz</td>\n",
" <td>2019-11-10 00:00</td>\n",
" <td>37.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>L5709000</td>\n",
" <td>CO</td>\n",
" <td>CO-VAU</td>\n",
" <td>NaN</td>\n",
" <td>1.257092</td>\n",
" <td>-70.233925</td>\n",
" <td>Aeropuerto Fabio Alberto León Bentley</td>\n",
" <td>2019-03-28 15:29</td>\n",
" <td>106.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>L6528209</td>\n",
" <td>CO</td>\n",
" <td>CO-CAQ</td>\n",
" <td>NaN</td>\n",
" <td>1.589800</td>\n",
" <td>-75.566046</td>\n",
" <td>Aeropuerto Gustavo Artunduaga Paredes</td>\n",
" <td>2020-02-17 12:39</td>\n",
" <td>65.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>L5587970</td>\n",
" <td>CO</td>\n",
" <td>CO-VAC</td>\n",
" <td>NaN</td>\n",
" <td>3.544004</td>\n",
" <td>-76.384077</td>\n",
" <td>Aeropuerto Internacional Alfonso Bonilla Aragón</td>\n",
" <td>2020-02-20 07:03</td>\n",
" <td>53.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>L4397568</td>\n",
" <td>CO</td>\n",
" <td>CO-AMA</td>\n",
" <td>NaN</td>\n",
" <td>-4.197502</td>\n",
" <td>-69.942755</td>\n",
" <td>Aeropuerto Internacional Alfredo Vásquez Cobo</td>\n",
" <td>2020-01-12 10:00</td>\n",
" <td>73.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>L4397562</td>\n",
" <td>CO</td>\n",
" <td>CO-DC</td>\n",
" <td>NaN</td>\n",
" <td>4.701969</td>\n",
" <td>-74.147050</td>\n",
" <td>Aeropuerto Internacional El Dorado</td>\n",
" <td>2020-02-02 06:26</td>\n",
" <td>68.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>L7668304</td>\n",
" <td>CO</td>\n",
" <td>CO-RIS</td>\n",
" <td>NaN</td>\n",
" <td>4.815392</td>\n",
" <td>-75.736557</td>\n",
" <td>Aeropuerto Internacional Matecaña</td>\n",
" <td>2020-01-23 07:13</td>\n",
" <td>80.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id country subnational1 subnational2 lat long \\\n",
"0 L7129862 CO CO-CAS NaN 4.895234 -71.457996 \n",
"1 L7750589 CO CO-NAR NaN 1.398537 -77.290474 \n",
"2 L2235118 CO CO-ANT NaN 6.218825 -75.587328 \n",
"3 L3800354 CO CO-ATL NaN 10.887591 -74.777369 \n",
"4 L5709000 CO CO-VAU NaN 1.257092 -70.233925 \n",
"5 L6528209 CO CO-CAQ NaN 1.589800 -75.566046 \n",
"6 L5587970 CO CO-VAC NaN 3.544004 -76.384077 \n",
"7 L4397568 CO CO-AMA NaN -4.197502 -69.942755 \n",
"8 L4397562 CO CO-DC NaN 4.701969 -74.147050 \n",
"9 L7668304 CO CO-RIS NaN 4.815392 -75.736557 \n",
"\n",
" name date num \n",
"0 AICA Bioparque Wisirare (CO206) 2019-12-24 10:57 145.0 \n",
"1 Aeropuerto Antonio Nariño 2019-05-04 14:45 35.0 \n",
"2 Aeropuerto Enrique Olaya Herrera 2019-12-22 10:00 40.0 \n",
"3 Aeropuerto Ernesto Cortissoz 2019-11-10 00:00 37.0 \n",
"4 Aeropuerto Fabio Alberto León Bentley 2019-03-28 15:29 106.0 \n",
"5 Aeropuerto Gustavo Artunduaga Paredes 2020-02-17 12:39 65.0 \n",
"6 Aeropuerto Internacional Alfonso Bonilla Aragón 2020-02-20 07:03 53.0 \n",
"7 Aeropuerto Internacional Alfredo Vásquez Cobo 2020-01-12 10:00 73.0 \n",
"8 Aeropuerto Internacional El Dorado 2020-02-02 06:26 68.0 \n",
"9 Aeropuerto Internacional Matecaña 2020-01-23 07:13 80.0 "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get list of all hotspots\n",
"hotspots_df = get_hotspots(region='CO')\n",
"hotspots_df.head(n=10)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['CO-CAS', 'CO-NAR', 'CO-ANT', 'CO-ATL', 'CO-VAU', 'CO-CAQ',\n",
" 'CO-VAC', 'CO-AMA', 'CO-DC', 'CO-RIS', 'CO-SAN', 'CO-MAG',\n",
" 'CO-CUN', 'CO-CAL', 'CO-QUI', 'CO-HUI', 'CO-TOL', 'CO-MET',\n",
" 'CO-CHO', 'CO-LAG', 'CO-CES', 'CO-CAU', 'CO-ARA', 'CO-BOY',\n",
" 'CO-PUT', 'CO-BOL', 'CO-NSA', 'CO-GUV', 'CO-GUA', 'CO-VID',\n",
" 'CO-COR', 'CO-SUC', 'CO-SAP'], dtype=object)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Show the unique subnational1 designations from the hotspot DF\n",
"hotspots_df.subnational1.unique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Species for a limited set of hotspots"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"# Hand-selected hotspots\n",
"selected_hotspots = [\n",
" 'L2241379', # Reserva Ecológica Río Blanco\n",
" 'L1252508', # PNN Los Nevados (Dept. Caldas)\n",
" 'L1433708', # SFF Otún Quimbaya\n",
" 'L7816358' # Hacienda El Bosque\n",
"] "
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get the most likely species in the hand-selected hotspots\n",
"selected_hotspot_species = set()\n",
"for hotspot in selected_hotspots:\n",
" selected_hotspot_species.union(get_likely_species(hotspot))\n",
"len(selected_hotspots)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"pd.DataFrame({\"Species\": selected_hotspots}).to_csv('./colombia_results/small_species_set.csv')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Species for all hotspots near the selected hotspots"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Automatically find all hotspots within a given distance of a set of selected hotspots\n",
"* Make a dictionary associating each hotspot with the list of species possible, above a certain frequency amount"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"within_distance_hotspots = {}\n",
"for hotspot in selected_hotspots:\n",
" within_distance_hotspots[hotspot] = get_hotspots_within_distance(\n",
" desired_hotspot = hotspot,\n",
" hotspots_df = hotspots_df,\n",
" max_distance_km = 200,\n",
" in_regions = ['CO-ANT', 'CO-CAL', 'CO-TOL', 'CO-RIS', 'CO-QUI', 'CO-CUN'], \n",
" in_regions_level = 'subnational1'\n",
" ).id.tolist()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"# Find a list of all species at selected and nearby hotspots\n",
"species_at_within_distance_hotspots = {}\n",
"for key, hotspots in within_distance_hotspots.items():\n",
" for hotspot in hotspots:\n",
" species_at_within_distance_hotspots[hotspot] = get_likely_species(hotspot, freq_sum_threshold=0.2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Select best hotspots"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"HOTSPOT_DICT = species_at_within_distance_hotspots\n",
"def collectors_curve_recursive(collection_hotspots = []):\n",
" '''\n",
" A recursive function which prioritizes hotspots\n",
" \n",
" Globals:\n",
" HOTSPOT_DICT : dictionary\n",
" keys: string hotspot location IDs\n",
" values: lists of species (strings)\n",
" \n",
" Arguments:\n",
" collection_hotspots : list of strings\n",
" list of string hotspot location IDs\n",
" '''\n",
" # Get a list of all unique species possible at \n",
" # previously identified collection_hotspots\n",
" base_spp_list = []\n",
" for spot in collection_hotspots:\n",
" base_spp_list.extend(HOTSPOT_DICT[spot])\n",
" base_spp_list = set(base_spp_list)\n",
"\n",
" # Find the hotspot that adds the most species to \n",
" # the base species list\n",
" best_partner = None\n",
" best_number = len(base_spp_list)\n",
" for hotspot, species in HOTSPOT_DICT.items():\n",
" partnership = base_spp_list.union(species)\n",
"\n",
" if len(partnership) > best_number:\n",
" best_number = len(partnership)\n",
" best_partner = hotspot\n",
" # After the above loop, best_partner == None if no partnership gave\n",
" # species list larger than that given by other hotspots. This can be \n",
" # caused by:\n",
" # - all remaining hotspots not having unique species to add\n",
" # - all hotspots already being added to collection_hotspots\n",
"\n",
" # Continue recursion if there are more hotspots to look through, or \n",
" # trigger return if there are no more to look through.\n",
" if best_partner == None:\n",
" return collection_hotspots\n",
" else:\n",
" collection_hotspots.append(best_partner)\n",
" return collectors_curve_recursive(collection_hotspots)\n",
"\n",
"HOTSPOT_DICT = species_at_within_distance_hotspots\n",
"best_hotspot_order = collectors_curve_recursive()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Examine results"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"19"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(best_hotspot_order)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"x = range(len(best_hotspot_order))\n",
"y = []\n",
"collectors_spp = set()\n",
"for spot in best_hotspot_order:\n",
" collectors_spp = collectors_spp.union(HOTSPOT_DICT[spot])\n",
" y.append(len(collectors_spp))"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEKCAYAAAAIO8L1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAHWZJREFUeJzt3X+cHWV59/HPlxBwFXWBRJts4pOAEEXRBFfKI4oRfAiilRhF4GWFKi3qQxVQ85RUK7SWgo2AUiuKYgHlhxHSgChGhCC1FXDzQ8IPAxGpZJMHYmURdYtJu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9Xwprb4EuEnZkNku4LbULHMZA2cBe1zSf6TP1ZLq2UC3pLuB89he+vvbwDtqndRkM4utTT/77ennGez7ZM0/P4hsqt3BTq91dAP9PHvWuBXAAbVOauDTZAn+7nTcT6ftLibryL+bbKbCu/J/azYWuJqrWcUk3UbW6dxTdSxm9XwFYWZmuXwFYWZmuXwFYWZmuZwgzMwslxOEmZnlcoIwM7NcThBmZpbLCcLMzHL9D1/hQbqZCFg+AAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"_ = plt.scatter(x, y)\n",
"plt.xlabel('Number of hotspots visited')\n",
"plt.xticks(range(0, len(best_hotspot_order), 2))\n",
"plt.ylabel('Species possible')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>country</th>\n",
" <th>subnational1</th>\n",
" <th>subnational2</th>\n",
" <th>lat</th>\n",
" <th>long</th>\n",
" <th>name</th>\n",
" <th>date</th>\n",
" <th>num</th>\n",
" </tr>\n",
" <tr>\n",
" <th>id</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>L2241379</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>5.069488</td>\n",
" <td>-75.441337</td>\n",
" <td>Reserva Ecológica Río Blanco</td>\n",
" <td>2020-02-21 06:15</td>\n",
" <td>548.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L1433708</th>\n",
" <td>CO</td>\n",
" <td>CO-RIS</td>\n",
" <td>NaN</td>\n",
" <td>4.725504</td>\n",
" <td>-75.571569</td>\n",
" <td>SFF Otún Quimbaya</td>\n",
" <td>2020-02-21 10:22</td>\n",
" <td>487.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L2841815</th>\n",
" <td>CO</td>\n",
" <td>CO-CUN</td>\n",
" <td>NaN</td>\n",
" <td>4.685108</td>\n",
" <td>-73.779717</td>\n",
" <td>PNN Chingaza--Carretera Chingaza</td>\n",
" <td>2020-02-01 07:03</td>\n",
" <td>174.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L759827</th>\n",
" <td>CO</td>\n",
" <td>CO-RIS</td>\n",
" <td>NaN</td>\n",
" <td>4.710976</td>\n",
" <td>-75.485945</td>\n",
" <td>Parque Regional Ucumari--La Pastora</td>\n",
" <td>2020-02-18 13:45</td>\n",
" <td>342.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L656882</th>\n",
" <td>CO</td>\n",
" <td>CO-CUN</td>\n",
" <td>NaN</td>\n",
" <td>4.730283</td>\n",
" <td>-74.149319</td>\n",
" <td>Parque La Florida</td>\n",
" <td>2020-02-21 05:52</td>\n",
" <td>333.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L6475198</th>\n",
" <td>CO</td>\n",
" <td>CO-RIS</td>\n",
" <td>NaN</td>\n",
" <td>4.711592</td>\n",
" <td>-75.670695</td>\n",
" <td>Parque Regional Natural Barbas-Bremen--Sendero...</td>\n",
" <td>2020-01-25 11:36</td>\n",
" <td>222.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L3653205</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>5.064713</td>\n",
" <td>-75.481589</td>\n",
" <td>Parque los Yarumos</td>\n",
" <td>2020-02-15 07:13</td>\n",
" <td>196.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L1252511</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>5.001850</td>\n",
" <td>-75.326967</td>\n",
" <td>Carretera Nevado del Ruiz</td>\n",
" <td>2020-02-15 07:00</td>\n",
" <td>199.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L4510695</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>5.018686</td>\n",
" <td>-75.403450</td>\n",
" <td>Reserva Forestal Protectora Bosques de La Chec</td>\n",
" <td>2020-01-25 11:11</td>\n",
" <td>269.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L2638098</th>\n",
" <td>CO</td>\n",
" <td>CO-RIS</td>\n",
" <td>NaN</td>\n",
" <td>4.702059</td>\n",
" <td>-75.535855</td>\n",
" <td>Parque Regional Ucumari--El Cedral</td>\n",
" <td>2020-02-06 09:46</td>\n",
" <td>355.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L5529238</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>5.042287</td>\n",
" <td>-75.444955</td>\n",
" <td>Recinto del Pensamiento</td>\n",
" <td>2020-02-14 07:03</td>\n",
" <td>237.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L5274571</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>4.897456</td>\n",
" <td>-75.340038</td>\n",
" <td>PNN Los Nevados--Hotel Termales del Ruiz</td>\n",
" <td>2020-01-09 14:00</td>\n",
" <td>148.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L5368913</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>5.060525</td>\n",
" <td>-75.487702</td>\n",
" <td>Universidad Católica de Manizales</td>\n",
" <td>2020-02-07 13:00</td>\n",
" <td>75.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L1252508</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>4.882857</td>\n",
" <td>-75.358658</td>\n",
" <td>PNN Los Nevados (Dept. Caldas)</td>\n",
" <td>2019-11-11 06:00</td>\n",
" <td>211.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L4462411</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>5.056434</td>\n",
" <td>-75.494345</td>\n",
" <td>Jardín Botánico de La Universidad de Caldas</td>\n",
" <td>2020-02-21 07:35</td>\n",
" <td>170.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L5817911</th>\n",
" <td>CO</td>\n",
" <td>CO-CAL</td>\n",
" <td>NaN</td>\n",
" <td>5.052659</td>\n",
" <td>-75.449888</td>\n",
" <td>Vereda Buenavista</td>\n",
" <td>2019-06-11 15:15</td>\n",
" <td>112.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L6269747</th>\n",
" <td>CO</td>\n",
" <td>CO-CUN</td>\n",
" <td>NaN</td>\n",
" <td>4.729468</td>\n",
" <td>-74.153278</td>\n",
" <td>Club de Golf La Florida</td>\n",
" <td>2020-02-08 07:55</td>\n",
" <td>80.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L2042218</th>\n",
" <td>CO</td>\n",
" <td>CO-RIS</td>\n",
" <td>NaN</td>\n",
" <td>4.728520</td>\n",
" <td>-75.577940</td>\n",
" <td>SFF Otún Quimbaya--Lodge</td>\n",
" <td>2020-02-20 17:51</td>\n",
" <td>399.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>L5588729</th>\n",
" <td>CO</td>\n",
" <td>CO-RIS</td>\n",
" <td>NaN</td>\n",
" <td>4.727972</td>\n",
" <td>-75.577222</td>\n",
" <td>SFF Otún Quimbaya--Sendero Bejucos</td>\n",
" <td>2020-02-05 09:37</td>\n",
" <td>231.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" country subnational1 subnational2 lat long \\\n",
"id \n",
"L2241379 CO CO-CAL NaN 5.069488 -75.441337 \n",
"L1433708 CO CO-RIS NaN 4.725504 -75.571569 \n",
"L2841815 CO CO-CUN NaN 4.685108 -73.779717 \n",
"L759827 CO CO-RIS NaN 4.710976 -75.485945 \n",
"L656882 CO CO-CUN NaN 4.730283 -74.149319 \n",
"L6475198 CO CO-RIS NaN 4.711592 -75.670695 \n",
"L3653205 CO CO-CAL NaN 5.064713 -75.481589 \n",
"L1252511 CO CO-CAL NaN 5.001850 -75.326967 \n",
"L4510695 CO CO-CAL NaN 5.018686 -75.403450 \n",
"L2638098 CO CO-RIS NaN 4.702059 -75.535855 \n",
"L5529238 CO CO-CAL NaN 5.042287 -75.444955 \n",
"L5274571 CO CO-CAL NaN 4.897456 -75.340038 \n",
"L5368913 CO CO-CAL NaN 5.060525 -75.487702 \n",
"L1252508 CO CO-CAL NaN 4.882857 -75.358658 \n",
"L4462411 CO CO-CAL NaN 5.056434 -75.494345 \n",
"L5817911 CO CO-CAL NaN 5.052659 -75.449888 \n",
"L6269747 CO CO-CUN NaN 4.729468 -74.153278 \n",
"L2042218 CO CO-RIS NaN 4.728520 -75.577940 \n",
"L5588729 CO CO-RIS NaN 4.727972 -75.577222 \n",
"\n",
" name date \\\n",
"id \n",
"L2241379 Reserva Ecológica Río Blanco 2020-02-21 06:15 \n",
"L1433708 SFF Otún Quimbaya 2020-02-21 10:22 \n",
"L2841815 PNN Chingaza--Carretera Chingaza 2020-02-01 07:03 \n",
"L759827 Parque Regional Ucumari--La Pastora 2020-02-18 13:45 \n",
"L656882 Parque La Florida 2020-02-21 05:52 \n",
"L6475198 Parque Regional Natural Barbas-Bremen--Sendero... 2020-01-25 11:36 \n",
"L3653205 Parque los Yarumos 2020-02-15 07:13 \n",
"L1252511 Carretera Nevado del Ruiz 2020-02-15 07:00 \n",
"L4510695 Reserva Forestal Protectora Bosques de La Chec 2020-01-25 11:11 \n",
"L2638098 Parque Regional Ucumari--El Cedral 2020-02-06 09:46 \n",
"L5529238 Recinto del Pensamiento 2020-02-14 07:03 \n",
"L5274571 PNN Los Nevados--Hotel Termales del Ruiz 2020-01-09 14:00 \n",
"L5368913 Universidad Católica de Manizales 2020-02-07 13:00 \n",
"L1252508 PNN Los Nevados (Dept. Caldas) 2019-11-11 06:00 \n",
"L4462411 Jardín Botánico de La Universidad de Caldas 2020-02-21 07:35 \n",
"L5817911 Vereda Buenavista 2019-06-11 15:15 \n",
"L6269747 Club de Golf La Florida 2020-02-08 07:55 \n",
"L2042218 SFF Otún Quimbaya--Lodge 2020-02-20 17:51 \n",
"L5588729 SFF Otún Quimbaya--Sendero Bejucos 2020-02-05 09:37 \n",
"\n",
" num \n",
"id \n",
"L2241379 548.0 \n",
"L1433708 487.0 \n",
"L2841815 174.0 \n",
"L759827 342.0 \n",
"L656882 333.0 \n",
"L6475198 222.0 \n",
"L3653205 196.0 \n",
"L1252511 199.0 \n",
"L4510695 269.0 \n",
"L2638098 355.0 \n",
"L5529238 237.0 \n",
"L5274571 148.0 \n",
"L5368913 75.0 \n",
"L1252508 211.0 \n",
"L4462411 170.0 \n",
"L5817911 112.0 \n",
"L6269747 80.0 \n",
"L2042218 399.0 \n",
"L5588729 231.0 "
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"try:\n",
" hotspots_df.set_index('id', inplace=True)\n",
"except KeyError:\n",
" print('index probably already set')\n",
"hotspots_df.loc[best_hotspot_order]"
]
},
{
"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.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment