how to add eventIDs to your occurrences file#
Thus far, we have only talked about setting up events and occurrence files individually.
However, they need to be linked by a common key so we know which occurrences were seen
at which event. Thus, we will link them via the eventID
column.
This step assumes that you have set up both your occurrence and event dataframes using the previous tutorials. If you haven’t, in the dropdown menu is the code for your perusal.
Code for occurrences and events thus far
>>> events = corella.use_events(dataframe=events,
... eventType='type',
... samplingProtocol='Observation',
... Event='name',
... event_hierarchy={1: "Site Visit", 2: "Sample", 3: "Observation"})
>>> events = corella.use_datetime(dataframe=events,eventDate='date',string_to_datetime=True,yearfirst=False,dayfirst=True)
>>> occ = corella.use_occurrences(dataframe=occ,
... basisOfRecord='HumanObservation',
... occurrenceStatus='PRESENT',
... occurrenceID=True)
>>> occ = corella.use_scientific_name(dataframe=occ,
... scientificName='Species')
>>> occ = corella.use_coordinates(dataframe=occ,
... decimalLatitude='Latitude',
... decimalLongitude='Longitude',
... geodeticDatum='WGS84',
... coordinatePrecision=0.1)
>>> occ = corella.use_datetime(dataframe=occ,
... eventDate='Collection_date',
... string_to_datetime=True,
... yearfirst=False,
... dayfirst=True)
corella
can automatically link your eventID``s in your events file to the occurrences by
comparing whether or not the date in the ``eventDate
column is the same. What this looks like
in principle is supplying three arguments:
add_eventID
: set this toTrue
if you wantcorella
to automatically add ``eventID``sevents
: provide the events dataframe containing the ``eventID``s to link.eventType
: specify theeventType
that you want to link to the occurrences. In this case,'Observation'
is the appropriate term.
The command will then look like this (using one of the commands in the dropdown as a template).
>>> occ = corella.use_occurrences(dataframe=occ,
... add_eventID=True,
... occurrenceStatus='PRESENT',
... occurrenceID=True,
... random_id=True,
... add_eventID=True,
... events=events,
... eventType='Observation')
>>> occ.head()
random
random
occurrenceID eventID scientificName decimalLatitude decimalLongitude eventDate number_birds geodeticDatum coordinatePrecision basisOfRecord occurrenceStatus
0 2abd4576-8baf-4183-b1db-eed51569747f ee329aa2-e2c4-491f-babe-74d645b1379f Eopsaltria (Eopsaltria) australis -20.29 148.7 2023-01-03 3 WGS84 0.1 HumanObservation PRESENT
1 2d67904b-2477-4561-bfa9-0bf19abb4b70 ee329aa2-e2c4-491f-babe-74d645b1379f Symposiachrus trivirgatus -20.29 148.7 2023-01-03 3 WGS84 0.1 HumanObservation PRESENT
2 78ded045-61b0-4056-bea2-69e327091b6a ee329aa2-e2c4-491f-babe-74d645b1379f Zosterops lateralis -20.29 148.7 2023-01-03 2 WGS84 0.1 HumanObservation PRESENT
3 b681d52f-d019-48dc-802e-ade5fbd32596 ee329aa2-e2c4-491f-babe-74d645b1379f Ptilinopus magnificus -20.29 148.7 2023-01-03 1 WGS84 0.1 HumanObservation PRESENT
4 5e0829a8-9f67-42c8-a929-ac9e80f0f70c ee329aa2-e2c4-491f-babe-74d645b1379f Pitta (Pitta) versicolor -20.29 148.7 2023-01-03 3 WGS84 0.1 HumanObservation PRESENT