The Atlas of Living Australia (ALA) is a comprehensive online repository of Australian flora and fauna: http://www.ala.org.au.

The package “ALA4R” exists at GitHub and is designed to allow the R community to directly access data and resources hosted by the ALA. The goal of the package is to enable outputs (e.g. observations of species) to be queried and downloaded in a range of standard formats.

A good introduction to the package is available at: http://github.com/AtlasOfLivingAustralia/ALA4R.

If you haven’t got them already you’ll need to install the packages “devtools” and “ALA4R”. The “ALA4R”" package (which isn’t on CRAN) can be accessed via “install_github”. Install and load “devtools” library before attempting “ALA4R” installation.

# Install packages "devtools" and "ALA4R"" if you haven't already (remove # tag below to activate)
# install.packages("devtools")
# you will likely receive warnings about Rtools this can be ignored

# "devtools" is a prerequesite for installation of ALA4R soload library
library(devtools)
## Warning: package 'devtools' was built under R version 3.1.3
## WARNING: Rtools is required to build R packages, but is not currently installed.
## 
## Please download and install Rtools 3.1 from http://cran.r-project.org/bin/windows/Rtools/ and then run find_rtools().
# Now attempt installation from github if you haven't already (remove # tag below to activate)
# install_github("AtlasOfLivingAustralia/ALA4R")

Set working directory:

Load libraries:

# Load remaining libraries
# you will likely receive warnings about rgeos -- this can be ignored for this example.

library(ALA4R)    # required to access ALA
library(ggplot2)  # required for graphics
library(maps)     # required for mapping
library(maptools) # required for mapping
## Loading required package: foreign
## Loading required package: sp
## Loading required package: grid
## Loading required package: lattice
## Checking rgeos availability: TRUE

Begin search:

# Search for Dendrolagus (genus of Tree Kangaroo)
search=search_fulltext("Dendrolagus")

# Download occurrences
TreeKangaroo=occurrences(taxon="Dendrolagus", download_reason_id=10)

# Save as data.frame
TreeKangaroo<-as.data.frame(TreeKangaroo$data)

Simplify dataframe:

# Search for Dendrolagus (genus of Tree Kangaroo)
dendro<-data.frame(TreeKangaroo$scientificName,
                   TreeKangaroo$latitude,
                   TreeKangaroo$longitude)
# Quick check
head(dendro)
##   TreeKangaroo.scientificName TreeKangaroo.latitude TreeKangaroo.longitude
## 1     Dendrolagus goodfellowi             -7.218297               146.8099
## 2     Dendrolagus goodfellowi             -7.380435               146.7138
## 3       Dendrolagus lumholtzi                    NA                     NA
## 4       Dendrolagus lumholtzi                    NA                     NA
## 5     Dendrolagus goodfellowi             -7.218297               146.8099
## 6     Dendrolagus goodfellowi             -7.380435               146.7138
# Simplify column names
colnames(dendro)<- c("species","latitude","longitude")

# Remove rows with missing values (NAs)
dendro<-na.omit(dendro)

# Save new dataframe
write.csv(dendro,"dendro.csv")

Make a simple map of all species entries:

# Using ggplot, plot the Base World Map
# create a layer of borders
mapWorld <- borders("world", colour="gray50",fill="gray50") 

ggplot() + 
  mapWorld +
  coord_equal(xlim = c(128, 154),ylim = c(-25, 5))+
  geom_point(data=dendro, aes(x=longitude, y=latitude,colour=species))