leaflet - R addPolygons function -
i trying add polygons map, i'm not sure why code not working. i've used same code before on other .shp files, , works fine. obtained spatial file here: http://library.queensu.ca/geo/health_regions. under ontario->local health integrated networks -> 2006 -> boundary files.
lhin<- readogr("lhin_divisions/hr035b08.shp",layer = "hr035b08") leaflet() %>% addtiles()%>%setview(lng=-81,lat=45,zoom=6) %>%addpolygons(data=lhin,stroke=true, weight=1, col='red')
i feel missing simple, can't figure out what?
the resulting map should have boundaries shown here:http://library.queensu.ca/madgic/free/health_regions/2005/images/lhin_ont.pdf
this work. can change tile color, used black , white since did not know looking for. shapefile in utm no projection. set projection , converted longlat.
proj4string(lhin) <- crs("+proj=utm +ellps=wgs84 +datum=wgs84") lhin <- sptransform(lhin, crs("+proj=longlat +ellps=wgs84 +datum=wgs84")) leaflet() %>% addprovidertiles("stamen.toner") %>% addpolygons(data=lhin,stroke=true, weight=1, color = ~"red")
Comments
Post a Comment