Sample Queries

These queries illustrate the power of the Semantic MediaWiki query language ("semantic search") and the Semantic MediaWiki query interfaces to extract data stored by the Flora of North America Semantic MediaWiki.

Click here to access the Semantic search query interface directly.

Query Size Limitations

Semantic MediaWiki software limits queries to 5,000 results. If you expect your query to return more than 5,000 results, you should run your query in batches. (N.B.: There are ~20,000 treatments in the FNA Online.)

To run your query in batches, we recommend splitting results by 'published volume'. You can do this by adding a volume condition to your query (e.g., "[[Volume::Volume 17]]"). Please see this page for a list of volumes that can be queried.

Queries by Subject

Taxonomy

Properties Used Query Syntax Query Interface Query Results Query the API
All Taxa in the Online FNA Taxon rank (see allowed values) [[Taxon rank::+]] Try it! R script

Python script

All Species in the Online FNA Taxon rank (see allowed values) [[Taxon rank::species]] Try it! R script

Python script

List of Lower Taxa Taxon parent [[Taxon parent::Carex]] Try it! In the genus Carex,... further results R script

Python script

List of Sections Taxon family (see allowed values)

Taxon rank (see allowed values)

[[Taxon family::Asteraceae]][[Taxon rank::section]] Try it! Sections in the family Asteraceae,... further results R script

Python script

Distribution

Properties Used Query Syntax Query Interface Query Results Query the API
Taxa occurring in Non-Abbreviated State or Province (i.e., Alaska, Idaho, Iowa, Maine, Nunavut, Ohio, Yukon) Distribution (see allowed values and Distribution Abbreviations) [[Distribution::Nunavut]] Try it! Taxa occurring in Nunavut,... further results R script

Python script

Taxa occurring in Abbreviated State or Province Distribution (see allowed values and Distribution Abbreviations) [[Distribution::Ont.]] Try it! Taxa occurring in Ontario,... further results R script

Python script

Publication Details

Properties Used Query Syntax Query Interface Query Results Query the API
Taxa by Authority Authority [[Authority::Linnaeus]] Try it! Taxa described by Linnaeus,... further results R script

Python script

Taxa by Publication Title Publication title [[Publication title::Proc. Amer. Acad. Arts]] Try it! R script

Python script

Taxa by Publication Year Publication year [[Publication year::1990]] Try it! R script

Python script

You can use comparators with the Publication year property. For example,

Taxa by Publication Year with Comparator Publication year [[Publication year::>>1990]] Try it! Taxa published after 1990,... further results R script

Python script

Special Status

Properties Used Query Syntax Query Interface Query Results Query the API
Taxa by Special Status Special status (see allowed values) [[Special status::Introduced]] Try it! Introduced species,... further results R script

Python script

Illustrations

Properties Used Query Syntax Query Interface Query Results Query the API
All Illustrated Taxa in the Online FNA Illustrator (see allowed values)

Illustration

[[Illustrator::+]][[Illustration::Present]] Try it! R script

Python script

List of Illustrations by Person Illustrator (see allowed values)

Illustration

[[Illustrator::Annaliese Miller]][[Illustration::Present]] Try it! Illustrations by Annaliese Miller,... further results R script

Python script

A list of illustrations, taxon name, taxon family, volume and illustrator Plate of taxon

Note that this query employs property chains

[[Plate of taxon::+]]|?Plate of taxon|?Plate of taxon.Taxon family=Taxon family|?Plate of taxon.Volume=Volume|?Plate of taxon.Illustrator=Illustrator Try it!

Volumes

Properties Used Query Syntax Query Interface Query Results Query the API
Treatments By Volume Volume (see allowed values) [[Volume::Volume 17]] Try it! Treatments published in volume 17,... further results R script

Python script

Contributors

Properties Used Query Syntax Query Interface Query Results Query the API
Treatments by Author Author [[Author::Bruce A. Ford]] Try it! Treatments authored by Bruce A. Ford,... further results R script

Python script

Advanced Queries

Composite Queries

You can combine any query elements from the above subjects to create a custom search.

For example,

Taxa with authority Linnaeus that occur in Nunavut [[Authority::Linnaeus]][[Distribution::Nunavut]]
Introduced species published in volume 3 [[Special status::Introduced]][[Volume::Volume 3]]
Taxa published before 1754 in the family Cyperaceae [[Publication year::<<1754]][[Taxon family::Cyperaceae]]

Comparators

You can use comparators with the Publication year property. (e.g., >, <, ).

Taxonomic Filtering

To return a dataset restricted to a taxonomic group, simply add a category filter:

Properties Used Category Used Query Syntax Query Interface Query Results
Elevation data for Carex Elevation Carex [[Category:Carex]]|?Elevation Try it! ... further results

When working with categories, precede your category request with only one colon.

Return More Information

You can return as many additional properties as you wish:

Query interface Query the API
Add property names to the Additional data to display box Add properties using the |? syntax:

[[Authority::Linnaeus]][[Distribution::Nunavut]]|?Taxon family|?Taxon rank|?Author

Write Your Own Queries

Click here to access the Semantic search query interface directly.

Note that:

  • The limit on the number of results returned can be changed
  • You can only export what is displayed on the page (JSON, CSV, RSS, RDF)
    • Page through the results to download each batch

Why use the API convenience scripts?

  1. For big queries, it may be cumbersome to download each batch of 500 results separately and then merge the results.
  2. If you are performing your analyses in R or Python, you may wish to embed the data extraction here, so that it can be easily re-run.

Access the convenience scripts here: https://github.com/jocelynpender/fna-query

Query Resources

Semantic MediaWiki Query Syntax

https://www.semantic-mediawiki.org/wiki/Help:Semantic_search

https://www.semantic-mediawiki.org/wiki/Help:Search_operators

Merging Multiple CSV Files

R script for merging multiple CSV files.

Working with APIs

Convenience scripts

https://github.com/jocelynpender/fna-query

Python

https://mwclient.readthedocs.io/en/latest/index.html

R

https://cran.r-project.org/web/packages/WikipediR/WikipediR.pdf