Shapefile – How to Fix Official London Shapefiles Not Working in R and Leaflet

leafletrshapefile

I am trying to map the Lower-layer Super Output Area (LSOA)of London. I could only find the shapefiles in this address:

https://data.gov.uk/dataset/6cdebf5d-c69b-4480-8c9c-53ab8a816b9d/statistical-gis-boundary-files-for-london

in the following zip file:

"statistical-gis-boundaries-london.zip"

Below is the code I'm using to map the shapfiles using R.

library(rgdal)
library(tidyverse)
library(leaflet)

lsao <- readOGR(dsn = "ESRI", layer = "LSOA_2011_London_gen_MHW") #Read the shapefiles from the ESRI folder

lsao %>% 
leaflet() %>%
  setView(-0.1000, 51.5,zoom = 10) %>% 
  addTiles() %>%
  addPolygons()

The above code just opens a Leaflet map with no polygons on the map. I have never had a problem mapping shapefiles using the above code and that's why I think there might be something wrong with the shapefiles on the UK government website. I was wondering if anyone has more information on this issue?

Best Answer

you can use below code:

lsao_london <- readOGR(dsn="folder name", layer="data name")
lsao_london <- spTransform(, CRS("+proj=longlat +datum=WGS84")) 
Related Question