Skip to content

Instantly share code, notes, and snippets.

@CampbellF
CampbellF / Density_from_SABAP2.R
Created August 1, 2019 11:11
Density and population size from SABAP2 data
# Example to get a density and population estimate for Karoo birds using publication
# https://tandfonline.com/doi/abs/10.2989/00306525.2018.1553804
# Title: Modelling bird atlas reporting rate as a function of density in the southern Karoo, South Africa
# Make sure these packages are installed
library(RCurl); library(dplyr)
# What is the mass of your bird?
# Here we use as example Karoo Scrub-Robin
mass <- 20
# What is the SABAP2 code for the species?
# Get this from: http://sabap2.adu.org.za/species
#Read in .csv from SABAP
occ<-read.csv("data.csv")
#retain only pentads with >4 cards with your species recorded
occ<-subset(occ,Cards_with_spp>4)
#retain only longitude and latitude of pentad centres and rename columns "lon, lat"
occ<-occ[,7:6]
names(occ)<-c("lon","lat")
#Convert sp spatial points DF
coordinates(occ) <- ~lon+lat
stdCRS <- CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
#Coverage Map
#===================================================
# Loading and installing packages -----------------------------------------
x <- c("ggmap", "rgdal", "rgeos", "maptools", "dplyr", "tmap",
"raster", "rJava","ggplot2", "sp")
install.packages(x)
lapply(x, library, character.only = TRUE)
@CampbellF
CampbellF / .R
Last active January 26, 2017 12:45
Libraries and pentad data
#Coverage Map
#===================================================
# Loading and installing packages -----------------------------------------
x <- c("ggmap", "rgdal", "rgeos", "maptools", "dplyr", "tmap",
"raster", "rJava","ggplot2", "sp")
install.packages(x)
lapply(x, library, character.only = TRUE)
#Read in the SABAP data