import pandas as pd
import folium
from datetime import datetime, timedelta
from pyinaturalist import (
Observation,
get_observations,
pprint,
)
import ipyplot
from itertools import compressA visit to Rwanda and Uganda
This post will contain a summary of my iNaturalist observations made during a visit to Rwanda and Uganda for the African Protected Areas Conference (APAC).
This post is still under development. I have not yet organised and uploaded all the observations, here is just a sample of them.
Load Python modules
I always start importing the python modules
Download iNaturalist observations
I use the get_observations function with a range of dates to query iNaturalist:
observations = get_observations(user_id='NeoMapas',
d1="2022-07-09",
d2="2022-07-25",
per_page=1000)Only three dozen or so observations so far (I guess this should be >60)
len(observations['results'])35
We can print them in a pretty table:
pprint(observations)ID Taxon ID Taxon Observed on User Location ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 328303999 3 Class Aves (Birds) Jul 22, 2022 neomapas Gasabo, RW-KV, RW 328303983 5418 Gypohierax angolensis Jul 22, 2022 neomapas Gasabo, RW-KV, RW (Palm-Nut Vulture) 328303950 3 Class Aves (Birds) Jul 22, 2022 neomapas Gasabo, RW-KV, RW 328303937 3 Class Aves (Birds) Jul 22, 2022 neomapas Gasabo, RW-KV, RW 328303913 71261 Order Accipitriformes (Hawks, Jul 22, 2022 neomapas Gasabo, RW-KV, RW Eagles, Kites, And Allies) 328303902 3 Class Aves (Birds) Jul 21, 2022 neomapas Gasabo, RW-KV, RW 328303886 71261 Order Accipitriformes (Hawks, Jul 21, 2022 neomapas Gasabo, RW-KV, RW Eagles, Kites, And Allies) 328303179 3 Class Aves (Birds) Jul 21, 2022 neomapas kimihurura 328303159 3 Class Aves (Birds) Jul 21, 2022 neomapas Kimihurura 328299630 47126 Kingdom Plantae (Plants) Jul 11, 2022 neomapas Volcans, RW-NO-MS, RW-NO, RW 328299589 47208 Order Coleoptera (Beetles) Jul 11, 2022 neomapas Volcans, RW-NO-MS, RW-NO, RW 328299575 47126 Kingdom Plantae (Plants) Jul 11, 2022 neomapas Volcans, RW-NO-MS, RW-NO, RW 328299560 47126 Kingdom Plantae (Plants) Jul 11, 2022 neomapas Volcans, RW-NO-MS, RW-NO, RW 328299544 47126 Kingdom Plantae (Plants) Jul 11, 2022 neomapas Volcans, RW-NO-MS, RW-NO, RW 328299524 47126 Kingdom Plantae (Plants) Jul 11, 2022 neomapas Volcans, RW-NO-MS, RW-NO, RW 328299500 47126 Kingdom Plantae (Plants) Jul 11, 2022 neomapas Volcans, RW-NO-MS, RW-NO, RW 328299479 47157 Order Lepidoptera (Butterflies Jul 11, 2022 neomapas Volcans, RW-NO-MS, RW-NO, RW And Moths) 328299454 47224 Superfamily Papilionoidea Jul 10, 2022 neomapas Gasabo, RW-KV, RW (Butterflies) 328110752 5268 Milvus migrans (Black Kite) Jul 09, 2022 neomapas Gasabo, RW-KV, RW 328110728 3 Class Aves (Birds) Jul 09, 2022 neomapas Gasabo, RW-KV, RW 328110711 721186 Ciconia ciconia ciconia Jul 09, 2022 neomapas Gasabo, RW-KV, RW (European White Stork) 252786946 329894 Genus Desmometopa Jul 12, 2022 neomapas Rubanda, Uganda 252786184 880641 Ariadne pagenstecheri Jul 12, 2022 neomapas Rubanda, Uganda 195608311 12792 Cossypha heuglini Jul 10, 2022 neomapas Kamukina, Kigali, Rwanda (White-Browed Robin-Chat) 169357877 32837 Trioceros johnstoni Jul 12, 2022 neomapas Kisoro, Uganda (Johnston's Chameleon) 169357874 12053 Lanius mackinnoni (Mackinnon's Jul 12, 2022 neomapas Kisoro, Uganda Shrike) 169357073 147661 Gorilla beringei beringei Jul 12, 2022 neomapas (-1.0333664656, (Mountain Gorilla) 29.6054448052) 169356800 31425 Genus Acanthocercus (Ridgeback Jul 23, 2022 neomapas Rugando, Kigali, Rwanda Agamas) 169356246 121993 Lampides boeticus (Pea Blue) Jul 16, 2022 neomapas Rugando, Kigali, Rwanda 169356060 55371 Saxicola torquatus (African Jul 14, 2022 neomapas HH97+MG, Kinigi, Rwanda Stonechat) 169355583 516815 Ceryle rudis rudis (African Jul 14, 2022 neomapas Located on Lake Mulehe 10Kms Pied Kingfisher) along Kisoro-Rubuguri Rd, Uganda 169355582 5268 Milvus migrans (Black Kite) Jul 14, 2022 neomapas Located on Lake Mulehe 10Kms along Kisoro-Rubuguri Rd, Uganda 169355580 12985 Muscicapa aquatica (Swamp Jul 14, 2022 neomapas Located on Lake Mulehe 10Kms Flycatcher) along Kisoro-Rubuguri Rd, Uganda 169354601 981195 Harpendyreus reginaldi Jul 13, 2022 neomapas Mount Sabyinyo, Congo - Kinshasa 169354599 8004 Corvus albicollis Jul 13, 2022 neomapas Mount Sabyinyo, Congo - (White-Necked Raven) Kinshasa
Map of observations
I have uploaded a selection of observation from different parts of my trip, including an excursion to the Volcanos National Park in Rwanda and the Bwindi National Park in Uganda.
map = folium.Map(tiles="Esri NatGeoWorldMap")fg = folium.FeatureGroup(name="iNaturalist observations", control=True, attribution="observers @ iNaturalist").add_to(map)
popup_text = """<img src='{url}'>
<caption><i>{species}</i> observed on {observed_on} / {attribution}</caption> {desc}
"""
for obs in observations['results']:
if obs['quality_grade'] == 'research':
if obs['description'] is None:
desc = ""
else:
desc = obs['description']
pincolor = 'green'
else:
desc = "Observation is not research quality grade."
pincolor = 'gray'
fg.add_child(
folium.Marker(
location=obs['location'],
popup=popup_text.format(
species=obs['species_guess'],
observed_on=obs['observed_on'],
desc=desc,
url = obs['observation_photos'][0]['photo']['url'],
attribution = obs['observation_photos'][0]['photo']['attribution']),
icon=folium.Icon(color=pincolor),
)
)
folium.LayerControl().add_to(map)<folium.map.LayerControl object at 0x127b99e50>
map.fit_bounds(map.get_bounds())
mapTravel log
records=list()
for obs in observations['results']:
record = {
'uuid': obs['uuid'],
'quality': obs['quality_grade'],
'description': obs['description'],
'location': obs['place_guess'],
'longitude': obs['location'][1],
'latitude': obs['location'][0],
'species guess': obs['species_guess'],
'Fecha': obs['observed_on'],
}
if len(obs['observation_photos'])>0:
record['url'] = obs['observation_photos'][0]['photo']['url']
record['attribution'] = obs['observation_photos'][0]['photo']['attribution']
records.append(record)inat_obs=pd.DataFrame(records)inat_obs["dia"]=inat_obs.Fecha.apply(datetime.date)inat_obs.groupby('dia').agg({'uuid': ['count'],'species guess': ['count',pd.Series.nunique]})| uuid | species guess | ||
|---|---|---|---|
| count | count | nunique | |
| dia | |||
| 2022-07-09 | 3 | 2 | 2 |
| 2022-07-10 | 2 | 2 | 2 |
| 2022-07-11 | 8 | 0 | 0 |
| 2022-07-12 | 5 | 5 | 5 |
| 2022-07-13 | 2 | 2 | 2 |
| 2022-07-14 | 4 | 4 | 4 |
| 2022-07-16 | 1 | 1 | 1 |
| 2022-07-21 | 4 | 3 | 2 |
| 2022-07-22 | 5 | 2 | 2 |
| 2022-07-23 | 1 | 1 | 1 |
my_observations = Observation.from_json_list(observations)images = [obs.photos[0].small_url for obs in my_observations]
labels = [str(obs) for obs in my_observations]Welcome to Kigali
ss = [datetime.date(obs.observed_on).strftime('%d/%m/%Y') in ['10/07/2022',] for obs in my_observations]
ipyplot.plot_images(list(compress(images, ss)), list(compress(labels, ss)), max_images=60,)Mount Bisoke
ss = [datetime.date(obs.observed_on).strftime('%d/%m/%Y') in ['11/07/2022',] for obs in my_observations]
#ipyplot.plot_images(list(compress(images, ss)), list(compress(labels, ss)), max_images=60,)Bwindi National Park
Gorilla expedition in Bwindi Impenetrable forest
Explore observations on iNaturalist
ss = [datetime.date(obs.observed_on).strftime('%d/%m/%Y') in ['12/07/2022',] for obs in my_observations]
ipyplot.plot_images(list(compress(images, ss)), list(compress(labels, ss)), max_images=60,)Mount Sabyinyo
ss = [datetime.date(obs.observed_on).strftime('%Y-%m-%d') in ['2022-07-13'] for obs in my_observations]
ipyplot.plot_images(list(compress(images, ss)), list(compress(labels, ss)), max_images=60,)Lake Mulehe
ss = [datetime.date(obs.observed_on).strftime('%Y-%m-%d') in ['2022-07-14'] for obs in my_observations]
ipyplot.plot_images(list(compress(images, ss)), list(compress(labels, ss)), max_images=60,)Observation(id=169355583, taxon=Taxon(id=516815, full_name=Ceryle rudis rudis (African Pied Kingfisher)), observed_on=Jul 14, 2022, username=neomapas, place_guess=Located on Lake Mulehe 10Kms along Kisoro-Rubuguri Rd, Uganda)
https://inaturalist-open-data.s3.amazonaws.com/photos/293602765/small.jpeg
Back in Kigali
ss = [datetime.date(obs.observed_on).strftime('%Y-%m-%d') in ['2022-07-16','2022-07-21','2022-07-22','2022-07-23',] for obs in my_observations]
ipyplot.plot_images(list(compress(images, ss)), list(compress(labels, ss)), max_images=60,)