A photo key to Montana's broadleaf trees
Source:vignettes/montana-hardwoods.Rmd
montana-hardwoods.RmdMontana has eleven native broadleaf (hardwood) trees, from the box elders and green ash of the eastern river bottoms to the aspen groves and paper birches of the mountains. This vignette shows a dichotomous key to them, written as a plain spreadsheet with a folder of photos, and the two ways dimoose can show it: a printable diagram and an interactive wizard.
Make your own key in three steps
The key is an ordinary CSV file, so the quickest way to write a key of your own is to start from a copy of it:
-
Copy the template. It ships with dimoose, next to its photos:
template <- system.file("extdata", "montana", package = "dimoose") dir.create("~/my-key") file.copy(template, "~/my-key", recursive = TRUE) # makes ~/my-key/montana/ -
Edit it in Excel, Numbers or Google Sheets. One row per lead:
Column What goes in it CoupletThe couplet’s number. ChoiceOptional: a,b, …; left blank, the leads are lettered in order.QuestionOptional: what the couplet asks, such as “Leaf type?”. DescriptionWhat the lead says. Goes toThe next couplet, or blank when the lead names a species. SpeciesThe result, written “Common name (Genus species)”. PhotoOptional: photo file names in the same folder, separated by ;.Put your photos in the same folder and save the sheet as CSV.
-
Build the key and look at it:
library(dimoose) k <- keyFromSpreadsheet("~/my-key/montana/montana-key.csv", desc = "My key") k$validate() # lists any couplet that is never reached, etc. keyDiagram(k, "my-key.svg") # a printable diagram exportWizard(k, "my-key.html") # an interactive key for phones and browsers
If a row points to a couplet that is not in the sheet, or names a
photo that is not in the folder, keyFromSpreadsheet() says
which spreadsheet row to fix.
The Montana key
library(dimoose)
k <- montanaKey()
k
#> <dimoose key> Key to the native broadleaf trees of Montana
#> 10 couplets, 20 leads, 11 taxa, up to 7 steps deepmontanaKey() is keyFromSpreadsheet()
applied to the template above. Its first rows:
csv <- system.file("extdata", "montana", "montana-key.csv", package = "dimoose")
head(read.csv(csv, check.names = FALSE), 4)
#> Couplet Choice Question
#> 1 1 a Leaf type?
#> 2 1 b Leaf type?
#> 3 2 a Leaflets?
#> 4 2 b Leaflets?
#> Description
#> 1 Leaves compound, divided into separate leaflets.
#> 2 Leaves simple, a single blade.
#> 3 Leaves opposite, with 3 (rarely 5) leaflets that have a few coarse teeth or shallow lobes.
#> 4 Leaves opposite, with 5 to 7 leaflets with toothed margins.
#> Goes to Species Photo
#> 1 2 fraxinus_pennsylvanica_leaf.jpg
#> 2 3 populus_deltoides_leaf.jpg
#> 3 NA Box elder (Acer negundo) acer_negundo_leaf.jpg
#> 4 NA Green ash (Fraxinus pennsylvanica) fraxinus_pennsylvanica_leaf.jpgEvery species was checked as native to Montana in the Montana Field Guide and USDA PLANTS. Common hackberry is left
out because the Montana Field Guide gives its origin in the state as
undetermined, and American elm because it is planted rather than native.
The characters in each couplet come from the Montana Field Guide’s
descriptions and, for leaf stalks and buds, the Virginia Tech Dendrology fact
sheets; ?montana lists the sources. The 14 photos are from
Wikimedia Commons, most of them taken in Montana by Matt Lavin; their
authors and licenses are in the package’s COPYRIGHTS
file.
A diagram of the key
keyDiagram() draws any key top-down: each question in a
blue box, its leads below it, and each species in a green box with its
photo.
keyDiagram(k, "montana-key.svg")An interactive key
exportWizard() writes the same key as a single web page
that asks one question at a time and shows the photos with each answer.
It works offline, so it can be copied to a phone and used in the
field.
page <- tempfile(fileext = ".html")
exportWizard(k, page)Open the file in a browser to try it.
Diagrams of other keys
keyDiagram() works on every dimoose key, whichever way
it was made. Here is the key to the orders of Arachnida, transcribed
from a textbook:
keyDiagram(arachnidaKey(), "arachnida.svg")