Advanced Annotation Filtering
The Basics
- What are annotations?
- Annotation values and definitions
- Using Identify module and adding annotations
- Filtering annotations with search URLs
- The most basic of this filtering can be done through the UI of the Identify module
The Fun Stuff
The above information will cover the majority of use cases for almost any users. But sometimes you want to filter things down just a bit more. The main limitation of the search URL functionality using the annotation options is the inability to filter on multiple different annotations. You can choose to include or exclude multiple values, but only within the same annotation. With a combination of annotation options and project options (both project_id= and not_in_project=) I made a feature request that was accepted, but it sounds like a lot would need to change for this to get implemented. So, as a workaround, I made projects for all different annotation values. I'm hoping one day for the search URLs functionality to be upgraded so all these projects aren't even necessary. Here is a link to the parent collection project. All the child projects can be found there (click "Read More" under the About section).
Annotation Projects
Examples
Observations with Life Stage - Adult and Sex - Female
Observations of Lepidoptera without any Life Stage annotation and without Evidence of Presence - Leafmine
Observations from the Antarctic Penninsula without ANY annotations
Observations with annotations for (Flowers OR Flower Buds) AND Fruits/Seeds
Discussion
As you can see, you can get quite detailed and complex with these search URLs. The main benefit of also using projects to search for annotations is the ability to search on multiple different annotations. But the hidden, less obvious perk is to be able to search with AND and OR. Comma separating projects in the url (both for project_id= and for not_in_project=) treats the search like an OR. The same goes for term_value_id=. So you can search for observations with Organisms or Tracks. But when you combine the two as I did in the last example, you can include only observations that meet both the project and annotation filter criteria. Unfortunately, since comma separating the urls treats it like an OR clause, we are still limited to two values that we can include or filter out. If the apply_project_rules_for filter worked as expected for annotation values (see this bug report), we would be able to bump that number up to three.
Another benefit I've discovered is the better handling of excluding an annotation. As you can see in the Lepidoptera example, it filters out only observations that have the leafmine annotation. If you were to try to replicate this with the annotation URL filters using without_term_id=22&without_term_value_id=32 (which cannot be configued with the UI), it will ignore the value_id. If you do term_id=22&without_term_value_id=32, it will filter out leafmine annotations, but only if the Evidence of Presence is filled with SOMETHING. So this is the only way to truly exclude what you want.
I wasn't sure if a tutorial or journal post was more appropriate, so I just copied it in my journal.
If you have any other use cases that I may not have covered here or if something I wrote doesn't make sense, leave a comment and maybe we can figure them out together.