Maps

Coral Reef Bleaching

1.Start with some coral reef data
 library(dplyr)
 library(ggplot2)
 library (rgdal)
 library (rgeos)
 library(maptools)
 library(tmap)

cb <- read.csv("CoralBleaching.csv")

2.Read in reef data with latitudes and longitudes
 b <- ggplot(cb, aes(LON, LAT)) + coord_cartesian(ylim=c(-40, 40), xlim=c(-200, 200))
 b + geom_point()
 b + geom_point(aes(color=cb$BLEACHING_SEVERITY))+scale_colour_brewer("Bleaching Severity", palette="PiYG")+ coord_equal(ratio=1)

reefvleach1

3. Add in a shapefile of coastlines
 coast <-readOGR("ne_50m_coastline.shp", layer="ne_50m_coastline")
 ggplot() + geom_polygon(data=coast, aes(x=long, y=lat, group=group))

4. Add your point data on the map and color according to bleaching severity
 ggplot() + geom_polygon(data=coast aes(x=long, y=lat, group=group), fill="grey40",
 colour="grey90", alpha=1)+labs(x="", y="", title="Coral Reef Bleaching")+ #labels
 theme(axis.ticks.y = element_blank(),axis.text.y = element_blank(),
 plot.title = element_text(lineheight=.8, face="bold", vjust=1))+space
 geom_point(aes(x=LON, y=LAT, color=BLEACHING_SEVERITY), data=cb, alpha=1, size=3, color="grey20")+geom_point(aes(x=LON, y=LAT, color=BLEACHING_SEVERITY), data=cb, alpha=1, size=2)+scale_colour_brewer("Bleaching Severity",
 palette="PiYG")+ coord_equal(ratio=1)

reefbleachpic

http://zevross.com/blog/2014/07/16/mapping-in-r-using-the-ggplot2-package/
http://www.sthda.com/english/wiki/ggplot2-colors-how-to-change-colors-automatically-and-manually
http://remi-daigle.github.io/GIS_mapping_in_R/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s