Common UK Lat/Long Errors and How to Spot Them

It is not uncommon for spatial data to have formatting or parsing problems, and new users can spend an awful lot of time troubleshooting what is usually a simple problem, whereas experienced users can often spot these errors just by the nature of the faulty output. For example, those working in with geographic data for the United Kingdom know that when their data points are turning up near the Seychelles, they have transposed (swapped) the latitude and the longitude! Below is a quick map (with accompanying code) that demonstrates this.


points <- tibble(long = c(-2.2426, 2.2426, -2.2426, 53.4808), 
                 lat = c(53.4808, 53.4808, -53.4808, -2.2426),
                 label = c("correct", "inverted long.", "inverted lat.", "transposed lat./long."),
                 colour = c("good", "bad", "bad", "bad"))

ggplot(mapping = aes(x = long, y = lat)) + 
  geom_polygon(data = map_data("world") , 
               aes(group = group),
               fill = "grey",
               colour = "grey50") +
  geom_point(data = points, aes(colour = colour)) +
  geom_label_repel(data = points,
                            aes(label = label, colour = colour)
                            ) +
  theme(legend.position = "none")