Pay to Play: Google API Keys and Mapping in R

In January 2019, Google updated their terms of service and has essentially removed the free access to Google Maps in R. This means that you’ll need to purchase the relevant APIs (compu-speak for Application Programming Interface) from Google in your google account to access these features in R.

So do you need it?

If you’re interested in mapping in R, you basically need it. There are some mapping packages that you can use to get around using any Google products (Leaflet is a great example). But for all the glorious customization and overwhelming ubiquity of the ggmap, this API key is essential for reproducible science in ecology related fields. When I first encountered the problem, troubleshooting was a nightmare–everyone used ggmap, and even those who didn’t still used Google Maps as a source for their base maps. Not. Fun.

Luckily, it’s relatively cheap at $2/month for the first 100,000 static maps in each month (dynamic maps, street maps, embed advance, and dynamic street maps cost more, but we aren’t likely using these tools in our work). Even luckier, there’s a $200 credit/month for the first year of use!

But how?

It’s a bit confusing to navigate the Google Cloud Console if you’re trying to figure it out solo (and scary considering you’re paying for something), but the actual steps are easy and quick. There are two main steps to the process: 1)Get an API key and 2) Show R your API key. There’s just a few ministeps in between.

Get an API key:

  1. Go to this website.
  2. Pick your product (Maps).
  3. Select a Project. If you don’t have one, create one. It won’t matter later.
  4. Enter your billing information.
  5. Copy your API key. Consider pasting it into a .txt file on your machine for safe keeping.

Show R your API key:

  1. In your R console, enter this code:
    • register_google(key = “YOUR_API_KEY”)
  2. Run this code for every new session you need to map in, and you’re ready to go!

a daRk tuRn

Open science is good for everyone!

R is popular among scientists (especially ecology/conservation scientists) because of its power. But it’s basically essential for scientists because it’s free. In a field where funding is scarce and costs are high, R has been a blessing for open science and has seriously moved the discipline forward. But the same reason R is powerful is because it’s not entirely autonomous; it (in large part) relies on monolithic companies like Google to up the ante. It may not be a very expensive fee, but it is yet another barrier for researchers and open science. Hopefully someday we can return to a free, open access Google Maps. After all, open science benefits scientists, the general public, and corporations–even Google.

Experiential Education Symposium at York University

I had a great time last week representing the Lortie lab and discussing work from my research practicum with president and vice chancellor of York university Rhonda Lenton. Aside from gaining wonderful feedback from her, which will definitely assist me in my future endeavours, I was thrilled to present the importance and impact of biology research with her as well as the many other influential attendees. I am excited and eager to experience the opportunities that lie ahead.

RuPaul’s Cactus Race: a baseline cactus size survey

What are the cacti?

For the bird-cactus double mutualism project, we had planned on observing two study species: Cylindropuntia anthrocarpa (Buckhorn Cholla) and Opuntia basilaris var. basilaris (Beavertail Cactus). We also needed 3 class sizes (small, medium, and large) in which to bin the cacti. This would impact our sample size and equipment list. That being said, the best laid plans of mice and men (and grad students) often go awry. I’d only briefly visited our study site the summer before I’d officially started at York, so we knew we would need to revisit Sunset Cove to do some preliminary exploration before getting into the trenches and collecting end-game data. Getting to the site, it was immediately apparent that we would need to examine our plants more closely; there was nearly no beavertail in sight. So we altered the protocol, then added Cylindropuntia enchinocarpa (Silver Cholla) into the mix. The goal? Determine the location, size, size-variability, and health. We want a tall-ish species (so pollinators and frugivores would be interested) with plenty of variability in size, enough of them to manipulate conditions, and healthy enough so we can expect some flowers and fruit later on. And, for fun, we took a quick look at shrubs to see if they’re associated with cacti in any respect (I don’t go into that here, but the data is available on Github).

Sunset Cove: a desert haven nestled in the Granite Mountains, and also our study site.

Where are the cacti?

Let’s make a quick map and take a look at the cacti individuals sampled. For C. anthrocarpa, we were easily able to sample at every 5 meters along 5 transects that were spaced 5 meters a part (n=105). C. enchinocarpa, however, was more sparsely distributed. So, after doing our first two transects 5 meters apart, we realized we needed to increase the distance between transects to 10 meters. We also weren’t able to get a cactus sample at every 5 meters, so we sampled 9 transects in total (n=98). The least common species, however, was Opuntia basilaris, which was so rare that transects were ineffective, so we instead unsystematically searched the entire site only to find a paltry number of individuals (n=26).

A quick map of the Cacti at Sunset Cove
Green = Buckhorn Cholla, Blue = Silver Cholla, Pink = Beavertail, Orange= Sunset Cove (Mapped in R using Leaflet)

Based on the proposed protocol, we need 150 individuals of each study species to replicate each combination of variables 10 times. Ideally, the individuals manipulated between flowering and fruiting season will not be resampled in the the fruiting season, as our manipulation of the flowers in April may impact the number of fruits in August. This means that C. anthrocarpa is a solid study species option. C. enchinocarpa is certainly possible, but not as dominant as its cousin, and O. basilaris is out of the question.

How big are the cacti?

We’ve seen the distribution of cacti, but size of the cacti is what’s really important for this study. We need to know if the sizes are variable enough to split into 3 class sizes (small, medium, and large). We also need a general idea of their height to consider if pollinating and frugivorous birds will engage with the flower and fruits of the cacti at all. The three species did indeed have significantly different mean heights (Kruskall Wallis Test, p > 0.0001, df = 52, x^2 = 151.52), with means of 1.04, 0.55, and 0.17 for Cylindropuntia anthrocarpa, Cylindropuntia echinocarpa, and Opuntia basilaris, respectively.

Cylindropuntia anthrocarpa is the tallest of the three, followed by Cylindropuntia enchinocarpa, with Opuntia basilaris being the smallest (p>0.0001)

How should we bin the cacti?

One important variable of our project is size classes within a species: small, medium, and large. Because height is what may influence pollination and frugivory, we will use the “z-axis” that we measured as the factor for size. Each size class must contain enough individuals for replication. We need to decide how to bin the size classes; either we can use natural breaks present in the data, or we can create equally-sized bins for the study species. Let’s examine each species’ size distribution, and make decisions about size class breaks on that.

None of the species have distributions with natural breaks (see density plots), and, especially for our two Cylindropuntia species, we can see that there are even distances between quartiles (see boxplots). For these reasons, I propose an equal-size binning method to determine size class.

Size-classes of cacti

But what exactly are the equal size classes for each species?

Cylindropuntia anthrocarpa<85cm86cm – 152cm>153cm
<45cm46cm – 72cm>73cm
Opuntia basilaris<15cm16cm – 22cm>23cm

We can see that Buckhorn Cholla (C. anthrocarpa) has the largest class sizes, followed by Silver Cholla, and then Beavertail. Having large classes may translate more clearly to birds, and therefore be a suitable metric to see if bird visitation is influenced by cactus size.

Health of cacti

Another important factor to consider when exploring potential study species is their overall health. After all, are these individuals even capable of flowering and fruiting? To measure health, we created a health index based on the Wind Wolves Bakersfield Cactus Report, which classifies each individual’s health on a discrete scale of 1-5 (1 being the least healthy, and 5 being the healthiest). We considered overall paddle/branch death, as well as scarification and rot.

Buckhorn and Silver Cholla both have a strong representation of 4 and 5 level health individuals, whereas Beavertail is equally distributed among all the health classes.

We can see that the Cylindropuntia species are healthier than their Opuntia counterparts. The question is, will an unhealthy population still flower/fruit as much as a healthy population? Perhaps, but this is not the question of my project.

Who is America’s Next Cactus Superstar?

Considering its abundance, size, and health, Opuntia basilaris is not a realistic contender as a study species. It is likely to be overlooked by birds, not bloom/fruit due to poor health, and is in small supply. Therefore I must remove it from the running. Both of Cylindropuntias are healthy. Silver Cholla, however, is still less dominant than Buckhorn Cholla, is smaller overall, and doesn’t have the width of size classes that Buckhorn Cholla does. While these traits do not mean the Silver Cholla could not be a viable study species, I propose that focusing more on Buckhorn Cholla by deepening the methods of observation (i.e., joy sampling: stationary versus mobile count data, and increased hours of focal observation) will be more beneficial to answering my study questions than a comparative study between cacti species would.

Buckhorn Cholla, Shantay you stay.

A workflow for pollen identification.

The reproductive ecology of cactus is not well-studied. A small, side project of mine is to determine the pollinator guild of buckhorn cholla at Sunset Cove, Mojave Desert, and with which plant species, if any, it shares pollinators. The genera Opuntia and Cylindropuntia are known to be insect-pollinated, but I am curious which of the more than 659 species of bees in the Mojave Desert desert are pollinators.

As visitation does not necessarily lead to pollination, I removed the pollen loads from 22 bee visitors I caught during insitu observation periods. I also removed stigma from the cholla to quantify heterospecific pollen deposition i.e. evidence of pollinator sharing. Pollen ID is not easy task and so I have developed a workflow to make it more streamlined.

Prep a reference collection:

  1. Create a reference collection by removing pollen from the anthers of several flowers of every species blooming in the area. Store in ethanol.
  2. Mount and stain the pollen with fushcin jelly.
  3. Image each species of pollen grain at 3 magnifications. Measure the length and width of about 10 grains per species. I calibrated Lumenera’s Infinity Analyze software using a stage micrometer to make this really quick.
  4. Make a reference document to consult. I use a word doc where every page is a species. Add in the photos at several magnifications, the mean size and any notes.
Sample reference page for Echinocereus engelmanni (Hedgehog cactus)

To go through the stigma or bee pollen load samples, I use my Canon EOS 60D dslr with a 60mm macro lens pointed confocally into a light microsite at 100x. I used the remote shooting utility from Canon to control the camera with my computer and display the view onto a second monitor.

Home example of confocal setup
  1. I designate each coverslip on the slide as a zone and do 8 transects through each, counting the grains. Each line in my spreadsheet is a transect, each column is a species. I use 5 columns for buckhorn so I never have to count very high.
  2. I don’t count damaged grains, or grains in air bubbles.
  3. Each slide gets its own folder. I take photos of each heterospecific grain with the file name as the zone + transect + species, which is simple using the photo utility. Knowing where the grain is on the slide and what its surroundings are will be helpful if you need to find it again.
  4. The species can be tentative for now so don’t get too bogged down.
  5. Take photos of unknowns when first encountered and assign them morphospecies ID. I put these in a separate folder as a reference.
  6. Some species are easy to ID. Quite a few are not. The more grains you see the easier it is to spot the differences.
  7. To help ID, we can take a page from entomologists. Sort the photos by their tentative IDs, putting each species in a folder so they are visible all at once (do a bulk rename to append the folder name first). It is difficult to compare grains unless they are side by side, which isn’t realistic with one microscope.
  8. Sort until each folder contains identical grains, then assign them a species from the reference collection. Or assign them to a species group for species that are virtually identical (likely Asteraceae!). Assign any remaining to morphospecies. Update the datasheet with the corrections.  
Buckhorn cholla (larger) and silver cholla (smaller). Thankfully the most abundant grains are simple to differentiate.

Commencement of Native vs. Exotic Competition

After a 2 month growing and censusing period, followed by a harvesting, drying, and biomass census I have concluded my 200 pot competition series.
During this period, I had obtained a photometer to measure light levels and did two light census for both the overall pot as well as below canopy. I am hoping that these light measures will provide quantifiable insight on the effect light has on growth. I hypothesize that plants receiving ambient light will yield greater mean biomass per species, while those in shade conditions (to mimic shrub presence) will have a greater mean height due to leggy growth.
I wanted to quantify the growth of my plants through several metrics, and therefore chose to obtain both height and leaf measurements for each species from each pot. In order to acquire these measurements, I implemented a new censusing technique for my second and final census. In this census I counted the number of individuals of each separate species there were per pot. Following this, I took the tallest individual of each species, and recorded its height along with the number of leaves. This way, following the harvest and mechanical oven drying period I would be able to compare the biomass of the plant with its height and leaf count. This would allow me to evaluate plant growth using two separate dimensions; plant height along and number of leaves vs. plant biomass.

After using a mechanical drying oven set to 62 degrees Fahrenheit for 48 hours, I used a precision scale to obtain the biomass of each plant.

The experiment planning, seed counting, pot filling, plant censusing, harvesting, and biomass analysis processing were extensive processes. I am extraordinarily grateful to Dr. Christopher Lortie, Dr. Jacob Lucero, Masters graduate Jenna Braun, research practicum student Anuja, and Economics and Finance student Denis Karasik for their time, efforts, and immense assistance with running this experiment.

Statistical analyses for all of the results are still in work, and I am eager to see the conclusion my experiment comes to.

Hours of biomass censusing in one photo

All the plants before the harvest

A flower from the beautiful Phacelia tanacetifolia
Plantago insularis also grew flowers

Biology for environmental management posters

Biology for environmental management class was an examination of the capacity for biological and ecological levers from primary research to be used for management and social good.


BIOL4265 posters


Quick notes on plant harvesting

Ok, our competition trials never look that good.

useful paper: Designs for greenhouse studies of interactions between plants


  1. Aboveground harvest: clip from soil surface.
  2. Belowground harvest: need to harvest entire plant at once by removing plants and roots from pot experiments (for instance) and gently washing to remove all soil but keeping roots and shoots intact.  Then, snip aboveground growth from below.
  3. Depending on level of replication and lowest possible independent sample unit, harvest one individual, one species, or all individuals of one species per pot into independent paper bags.
  4. Place in ovens at 68F for at least 2 days.
  5. Leave all plants in paper bags in oven until the moment you are ready to weigh.
  6. Remove from paper bags to weigh for small plants. Typically, I weigh to 3-4 decimal grams for small desert annual plants.
  7. Return plants to bag, do not return to oven, store in a paper box for a few weeks or until all data entered and checked.

Interesting Camera Trap Videos from Carrizo Summer 2018


A video showing a Jack Rabbit Pooping at night, in the Carrizo Plain. One of the videos I have found while going through my camera trap data.


Similar to the previous post showing the Shrike take-off. This one shows it from a side profile.


A video of a Kitfox interacting with the camera trap at night. It seems that it has taken an interest in it and is a little curious.


Now that the Kitfox is gone, we have 2 Kangaroo Rats in view. Seems that they are foraging for some food to eat. This video was a few hours after the Kitfox was around.


The final video shows a Jack Rabbit early in the morning taking an interest in the Camera Trap. Similar to the Kitfox, it seems that the animals are a little curious.