Usage

At a low level, inattrails provides Python code to download named roads and trails and also iNaturalist observations along hiking trails. This functionality may be used in other Python projects. They are described in the Detailed API Documentation section.

At a higher level, Utility inat-trails reads the route of a hike and generates a table of iNaturalist observations along the way. It also displays the observations and the route of the hike on a map. It also stores waypoints of the iNaturalist observations for offline navigation with a GPS device or smartphone.

Installation

Package inattrails provides utility inat-trails and it runs on Python 3.7 or higher and can be installed with pip.

$ pip install inattrails

Utility inat-trails

Besides a Python package this is a command-line tool. It is called with a .gpx file describing the route. This .gpx file can either be downloaded after a hike from a gps device or smartphone or created before a hike by a mapping tool or website. The gpx files in the examples directory have been created using the free website caltopo.com.

This is an example where we first download one of gps tracks from inat-trail’s examples:

wget https://github.com/joergmlpts/iNat-trails/raw/master/examples/Rancho_Canada_del_Oro.gpx
inat-trails Rancho_Canada_del_Oro.gpx

The output looks like this:

Reading 'examples/Rancho_Canada_del_Oro.gpx'...
Loaded 13 named roads and trails: Bald Peaks Trail, Canada Del Oro Cut-Off Trail, Canada Del Oro Trail, Casa Loma Road,
  Catamount Trail, Chisnantuk Peak Trail, Little Llagas Creek Trail, Llagas Creek Loop Trail, Longwall Canyon Trail,
  Mayfair Ranch Trail, Needlegrass Trail, Serpentine Loop Trail.
Loaded 2,708 iNaturalist observations of quality-grade 'research' within bounding box.
Excluded 1,694 observations not along route and 13 with low accuracy.
Loaded 829 taxa.
Waypoints written to './Rancho_Canada_del_Oro_Open_Space_Preserve_all_research_waypoints.gpx'.
Table written to './Rancho_Canada_del_Oro_Open_Space_Preserve_all_research_observations.html'.
Map written to './Rancho_Canada_del_Oro_Open_Space_Preserve_all_research_mapped_observations.html'.

This tool finds named trails along this route. It loads iNaturalist observations from the area of the hike and discards those that are not along the trails. It writes three output files, a waypoints file, a table of observations, and an interactive map. Both the table and the map are displayed in the browser.

The waypoint file can be loaded into the free offline navigation app OsmAnd. This allows this offline navigation app to display the iNaturalist observations along the hiking trails.

The interactive map shows the route and the iNaturalist observations along the hike. Like the iNaturalist website, the markers on the interactive map have different colors for different iconic taxa, e.g. markers for plants are green. Hovering the mouse over a marker shows the identification, clicking on a marker shows a thumbnail image, the identification, the observer, the date and a special status such as invasive or introduced. Another click on the thumbnail opens the observation on the iNaturalist website in another browser window.

image of interactive map

The table of observations lists all the organisms that have been observed along the trails together with the trail names where they were found. The table for mammals seen in this park looks like this:

Scientific NameCommon NameObservations
CanidaeCanids
Canis latransCoyoteMayfair Ranch Trail: 38860133, 38860889
Urocyon cinereoargenteusGray FoxBald Peaks Trail: 169320230, 169346468; Mayfair Ranch Trail: 39391329, 82367061, 119805725
CervidaeDeer
Odocoileus hemionusMule DeerLittle Llagas Creek Trail: 97091190
CricetidaeHamsters, Voles, Lemmings, and Allies
Neotoma fuscipesDusky-Footed WoodratMayfair Ranch Trail: 52963985
FelidaeFelids
Lynx rufusBobcatMayfair Ranch Trail: 15630740, 15689757, 38861135
GeomyidaePocket Gophers
Thomomys bottaeBotta's Pocket GopherMayfair Ranch Trail: 126903, 38869384, 38875049, 182278119
LeporidaeHares and Rabbits
Sylvilagus bachmaniBrush RabbitMayfair Ranch Trail: 47200364, 73152597, 74462983, 115787696, 138449617, 154909507, 156000421, 171638196, 181314717
SciuridaeSquirrels
Neotamias merriamiMerriam's ChipmunkLongwall Canyon Trail: 42605223; Mayfair Ranch Trail: 132863, 15351304, 46538314
Otospermophilus beecheyiCalifornia Ground SquirrelCasa Loma Road: 47200360; Llagas Creek Loop Trail: 152200928; Mayfair Ranch Trail: 133882, 2328803, 15629491, 53667091, 72054474, 102356238, 107205485, 115031588, 121910880, 152201141, 160174643, 175808922
Sciurus griseusWestern Gray SquirrelMayfair Ranch Trail: 73152599, 182278583
SoricidaeShrews
Sorex vagransVagrant ShrewMayfair Ranch Trail: 120889692

The numbers are the observation ids; clicking on them opens the observation on the iNaturalist website. The –login_names option can be used to replace these observation ids with login names.

Command-line arguments

This script is a command-line utility. It is called with options and filenames as arguments. These options are supported:

$ inat-trails -h
usage: inat-trails [-h] [--quality_grade QUALITY_GRADE] [--iconic_taxon ICONIC_TAXON] [--login_names] gpx_file [gpx_file ...]

positional arguments:
  gpx_file              Load GPS track from .gpx file.

optional arguments:
  -h, --help            show this help message and exit
  --quality_grade QUALITY_GRADE
                        Observation quality-grade, values: all, casual, needs_id, research; default research.
  --iconic_taxon ICONIC_TAXON
                        Iconic taxon, values: all, Actinopterygii, Amphibia, Animalia, Arachnida, Aves, Chromista,
                        Fungi, Insecta, Mammalia, Mollusca, Plantae, Protozoa, Reptilia; default all.
  --login_names         Show login name instead of numeric observation id in table of observations.
  --month               Show only observations from this month and the previous and next months.
quality_grade

The –quality_grade option spcifies the desired quality-grade of the observations to be shown. By default, only research-grade observations are shown. Alternatively, all quality grades, or only casual and needs_id can be requested.

iconic_taxon

The –iconic_taxon option allows to restrict the observations to an iconic taxon. This can be used to display observations of e.g. only birds or only plants.

login_names

The –login_names option replaces the observation id number with the login name in the table of observations.

month

The –month option restricts observations to the current month and the previous and next months. This is useful for seasonal observations such as wildflowers or migratory birds.