Skip to content

Scotland dataset CRS #40

@simon-smart88

Description

@simon-smart88

Hello. I wanted to use the Scotland dataset as an example dataset, but needed to convert to latitude/longitude first. I'd normally do that with sf::st_transform(scotland_sf, crs = 4326) but the result ends up plotted in the South Pacific and is very small:

library(leaflet)
library(SpatialEpi)

scot <- scotland_sf
scot <- sf::st_transform(scot, crs = 4326)
leaflet() %>%
  addProviderTiles("Esri.WorldTopoMap") %>%
  addPolygons(data = scot)

Looking at the raw values in the geometry, I noticed that the values looked 1000 times too small for eastings and northings and indeed transforming the values fixes the issue:

scot$geometry <- scot$geometry * 1000
scot <- sf::st_set_crs(scot, 27700) 
scot <- sf::st_transform(scot, crs = 4326)
leaflet() %>%
  addProviderTiles("Esri.WorldTopoMap") %>%
  addPolygons(data = scot)

Maybe I have misunderstood the original CRS, but if not you may want to consider converting the object with either the first two or three lines of the above. This was using the sf version, but I also noticed that the sp version has the same coordinates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions