I did a map!

I have been playing with R’s capacity to produce interactive maps and (after much trial-and-error) have finally come up with something that shows an interesting pattern.  The data plotted below are the species richness of dragonflies and damselflies from the British Dragonfly Society‘s database in West Yorkshire over the last 20 years.  The data are summarised to 1km grid squares on the British National Grid.  Below is a screenshot because WordPress doesn’t like iframes, but click it to go to the full map.

Capture

The scale is a bit odd to emphasise the range of the data, and there are many neater ways to do this.  In particular, R gives the option to render in interactive 3D using OpenGL, create actual interactive maps using Shiny, and use the Leaflet jscript packages.  There are more details on the plotGoogleMaps package that I used for this little map here.  The code is below:

Dragonfly.grid <- read.table("Dragonfly data.txt",header=TRUE)
attach(Dragonfly.grid)
Dragonfly.grid[,2]<-Dragonfly.grid[,2]*100
Dragonfly.grid[,3]<-Dragonfly.grid[,3]*100
library(RColorBrewer)
coordinates(Dragonfly.grid)<-c('Easting','Northing')
Dragonfly.grid<-as(Dragonfly.grid,'SpatialPixelsDataFrame')
proj4string(Dragonfly.grid) <- CRS('+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs')
m=plotGoogleMaps(Dragonfly.grid,zcol='Species',at=c(0,2,3,4,6,8,12,21),colPalette= rev(rainbow(7,start=0,end=4/6)))

Created by Pretty R at inside-R.org

Advertisement

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 )

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