Here, I present a short procedure for converting British National Grid coordinates into latitude and longitude coordinates.
Background
Many times, I have received data using the British National Grid coordinate system (OSGB36 datum, EPSG code: 27700; also known as the Ordnance Survey National Grid). It is excellent that these spatial data are collected and I implore people to continue to record where observations are collected.
Most spatial analyses are, however, written with more generic coordinate systems in mind. One such coordinate system is the World Geodetic System (WGS84 datum, EPSG code: 4326), which is the reference coordinate system for Global Positioning System.
I often want to use the spatial data in analyses, or at least to verify visually that they look correct, and this is easiest when the spatial data is in WGS84. So, I convert the coordinates.
Below is a generic version of the script that I use.
R script
# read in csv data; first column is assumed to be Easting and second Northing
<- read.csv('BNGpoints.csv')
dat
# rename columns
colnames(dat)[c(1, 2)] <- c('Easting', 'Northing')
# libraries
require(rgdal) # for spTransform
require(stringr)
## shortcuts
<- "+init=epsg:27700"
ukgrid <- "+init=epsg:4326"
latlong
## Create coordinates variable
<- cbind(Easting = as.numeric(as.character(dat$Easting)),
coords Northing = as.numeric(as.character(dat$Northing)))
## Create the SpatialPointsDataFrame
<- SpatialPointsDataFrame(coords,
dat_SP data = dat,
proj4string = CRS("+init=epsg:27700"))
## Convert
<- spTransform(dat_SP, CRS(latlong))
dat_SP_LL
# replace Lat, Long
@data$Long <- coordinates(dat_SP_LL)[, 1]
dat_SP_LL@data$Lat <- coordinates(dat_SP_LL)[, 2]
dat_SP_LL
# optionally write out as shapefile
writeOGR(obj = dat_SP_LL, dsn = '.', layer = 'BNGpoints', driver = 'ESRI Shapefile')
Here is an example of salmon redd locations converted from BNG to WGS84 and plotted on a shapefile of the river Frome, Dorset, UK.
I hope this is useful to someone.
Reuse
Citation
@online{d. gregory2017,
author = {D. Gregory, Stephen},
title = {Coordinate Conversions in {R}},
date = {2017-01-07},
url = {https://stephendavidgregory.github.io/posts/ukgrid-to-latlong},
langid = {en}
}