I have shape data for London, and want to colour different regions red, yellow, and green.
My code works, but does not fill it according to red, yellow, or green.
The data is: https://data.london.gov.uk/dataset/statistical-gis-boundary-files-london
Here is my code:
library("rgdal")
library(leaflet)
shapeData <- readOGR('statistical-gis-boundaries-london/ESRI/LSOA_2004_London_Low_Resolution.shp')
shapeData <- spTransform(shapeData, CRS("+proj=longlat +ellps=GRS80"))
LANAME='Camden'
shapeData$col=sample(c('red','yellow','green'),nrow(shapeData),1)
leaflet() %>% addTiles() %>%
setView(lng = -0.106, lat=51.5177,zoom=14) %>%
addPolygons(data=bor,weight=2,col = 'black',fillOpacity = 0.02,fillColor = shapeData$col,
highlightOptions = highlightOptions(color='white',weight=1,
bringToFront = TRUE)) %>%
addMarkers(lng = -0.106,lat=51.5177,popup="Hi there")
The output is:
Can anyone point out why I do not see yellow, green, or red only, and see all these other colours as well.
Thanks
