0

I am struggling to plot points using WGS84 co-ordinates on a map of the UK using the OSGB 1936 / British National Grid CRS. I'm using the rgdal package in R.

Here is my reproducible example, using the co-ordinates of Buckingham Palace...

library(rgdal)
foo <- data.frame(lat = 51.500829, long = -0.142994)
bar <- SpatialPoints(foo)
proj4string(bar) <- CRS("+init=epsg:4326")
bar <- spTransform(bar, CRS("+init=epsg:27700"))
coordinates(bar)

This outputs the following transformed co-ordinates:

         lat     long
[1,] 7464126 -5554500

Where I should be getting latitude of 179622 and longitude of 528993.

Can anyone tell me what I'm doing wrong? The only similar problem I could find was here and I'm now pretty confident I am choosing the right CRSs. I'm trying to do something similar to this post but again, I don't think the solutions there can help me.

P.S. I'm using this site to check what co-ordinates I should be getting.

Tom Wagstaff
  • 125
  • 4

1 Answers1

1

Short answer: x is longitude and y is latitude. (For geographic coordinates. East and north for projected coordinates)

Solution:

library(rgdal)
foo <- data.frame(y = 51.500829, x = -0.142994) # lat == y, long == x
coordinates(foo) <- ~x+y
proj4string(foo) <- CRS("+init=epsg:4326")
bar <- spTransform(foo, CRS("+init=epsg:27700"))
coordinates(bar)
##          x        y
## 1 528992.9 179622.5
aldo_tapia
  • 13,560
  • 5
  • 30
  • 56