Data Extraction from Observation Fields

crab_baguette on the main site is looking to gather seasonality data of termite nuptial flights. I just created the Termite Imago(s) field with a “Flight Evidence” option to mark observations with evidence of flights. Slowly, the field should get filled up with plenty of observations. What I’m wondering now is how we can best extract the seasonality data from observations within the field for each taxon/location etc. I would like to avoid creating a project as some users are opted out (thus somewhat skewing data), but I’m open to using one if necessary. Either way, project needed or not, how can we export the data? The end goal would be to preferably create a graph with the data similar to that of annotations.

1 Like

I would go to the export page and query for all observations that have your field:

You can then change what else is included in the export – it sounds like you want taxon, location, and date. With the data downloaded, you can use whatever data processing/visualization software you prefer.

2 Likes

iNat’s CSV export is fine if you really need the underlying information about individual observations, or if you plan slice and dice a single set of data in many ways. but if you’re just trying to make seasonality graphs or charts, then getting observation histogram data via the API is probably a more efficient way to get what you need (since it gives you aggregated data).

when the system is back up, i can provide some more information on this approach, if needed.

I tried out the export function and it worked fine (besides the interface bugging a bit), but that would also be great if you get the chance – perhaps the API could be used to make automatically updating graphs at whatever interval, and then that could be displayed on a site or Discord bot etc. So far, for the CSV data, I just exported a list of dates and used a pivot table to organize by month, and then graphed here. In the future, especially as more data is collected, I’d like to make comparison graphs of species to directly compare their flight times, or even compare the flight times of individual species within different geographical regions (not sure what type of graph would be good for this, maybe just overlapping line graphs/scatter plots). Unfortunately, I’m terrible at using sheets so I don’t know how I’d even do that yet (API may help?).
Thanks for the idea.

you can find the available parameters for the API’s observation histogram endpoint at: https://api.inaturalist.org/v1/docs/#!/Observations/get_observations_histogram

i think the data for your graph, assuming place_id=64492 (Northeastern US) and taxon_id=119933 (genus Reticulitermes), could be obtained via this API request:

https://api.inaturalist.org/v1/observations/histogram?interval=month_of_year&date_field=observed&field%3ATermite+Imago(s)=Flight+Evidence&place_id=64492&taxon_id=119933

it returns:

{
   "total_results":12,
   "page":1,"per_page":12,
   "results": {
      "month_of_year: {
         "1":0,
         "2":0,
         "3":6,
         "4":19,
         "5":101,
         "6":18,
         "7":1,
         "8":0,
         "9":0,
         "10":0,
         "11":0,
         "12":0
      }
   }
}

you can use your favorite scripting language or data analytics tool get the data from the API and create whatever kind of chart or graph you like.

for example, this page will visualize the data in a bar chart like yours:
https://jumear.github.io/stirfry/iNatAPIv1_observation_histogram?interval=month_of_year&date_field=observed&field:Termite%20Imago(s)=Flight%20Evidence&place_id=64492&taxon_id=119933

or here’s an example of a line graph done in R: https://forum.inaturalist.org/t/1m-observations-this-month/2582/4

and here’s an explanation of how to make a bar chart using Excel: https://forum.inaturalist.org/t/using-excel-api/22378#step-5-optional-column-chart-of-observations-by-day

let me know if you need any other information.

EDIT: i just remembered that if

iNat has an “experimental” Compare tool, which could help you create comparison graphs like so: