Skip to content

Instantly share code, notes, and snippets.

@mcdlee
Created February 12, 2014 16:16
Show Gist options
  • Select an option

  • Save mcdlee/8958753 to your computer and use it in GitHub Desktop.

Select an option

Save mcdlee/8958753 to your computer and use it in GitHub Desktop.
from address to GPS, geojson then maps.
hosp_list <- read.csv("~/Dropbox/tmp/python/list.csv", fileEncoding="UTF-8")
gps <- read.csv("~/Dropbox/Public/kaohsiung_gps.csv")
attach(hosp_list)
hosp_list$clinicRef <- as.factor(clinicRef)
hosp_list$groupRef <- as.factor(groupRef)
hosp_list$hos1Ref <- as.factor(hos1Ref)
hosp_list$hos2Ref <- as.factor(hos2Ref)
hosp_list$hos3Ref <- as.factor(hos3Ref)
hosp_list$hos4Ref <- as.factor(hos4Ref)
library(ggmap)
library(leafletR)
library(scales)
kaoh_clin <- subset(hosp_list, city=="高雄市")
for(i in 1:length(kaoh_clin)){
kaoh_clin[i] <- droplevels(kaoh_clin[i])
}
kaoh_clin <- cbind.data.frame(gps, kaoh_clin)
grouplist <- as.vector(levels(kaoh_clin$groupName))
hos_list <- as.vector(levels(kaoh_clin$hos1Name))
s.dat <- toGeoJSON(data=kaoh_clin, lat.lon=c("lat", "lon"))
s.sty <- styleCat(prop="groupName",val=grouplist, style.val= hue_pal()(length(grouplist)))
s.map <- leaflet(data=s.dat, style=s.sty, base.map = c("osm", "cm", "mqosm"), popup="clinicRef")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment