Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Created November 1, 2015 04:09
Show Gist options
  • Select an option

  • Save yutannihilation/154005aca91f6a760a4a to your computer and use it in GitHub Desktop.

Select an option

Save yutannihilation/154005aca91f6a760a4a to your computer and use it in GitHub Desktop.
d2 <- data_frame(orig_id = sapply(l_union@polygons, function(x) x@ID)) %>%
mutate(target_id = str_split(str_to_lower(orig_id), " ")) %>%
rowwise() %>%
summarise(orig_id, target_id = target_id[1])
d2[13,"target_id"] <- "hokkaido"
d_ordered <- left_join(d, d2, by = c("pref_alpha" = "target_id"))
rownames(d_ordered) <- d_ordered$orig_id
s <- SpatialPolygonsDataFrame(l_union, as.data.frame(d_ordered))
leaflet(s) %>%
addPolygons(color = ~color_generator(チョコレート), fillOpacity = 1, stroke = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment