Last active
April 24, 2017 19:34
-
-
Save cavedave/1226a92cbe5019fa0a9b04b74fe00ee6 to your computer and use it in GitHub Desktop.
Map of ireland code taken from https://gist.github.com/halhen/659780120accd82e043986c8b57deae0 and data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
France | |
filter(lng > 32, lng < 44) %>% | |
filter(lat > 22, lat < 31) %>% | |
Italy | |
+ filter(lng > 40, lng < 51) %>% | |
+ filter(lat > 14.7, lat < 26) %>% | |
Germany | |
filter(lng > 40, lng < 48) %>% | |
filter(lat > 26, lat < 36) %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read_csv('GEOSTAT_grid_POP_1K_2011_V2_0_1.csv') %>% | |
rbind(read_csv('JRC-GHSL_AIT-grid-POP_1K_2011.csv') %>% | |
mutate(TOT_P_CON_DT='')) %>% | |
mutate(lat = as.numeric(gsub('.*N([0-9]+)[EW].*', '\\1', GRD_ID))/100, | |
lng = as.numeric(gsub('.*[EW]([0-9]+)', '\\1', GRD_ID)) * ifelse(gsub('.*([EW]).*', '\\1', GRD_ID) == 'W', -1, 1) / 100) %>% | |
filter(lng > 28, lng < 34) %>% | |
filter(lat > 28, lat < 34) %>% | |
group_by(lng=round(lng, 1), lat=round(lat, 1)) %>% | |
summarize(value = sum(TOT_P, na.rm=TRUE)) %>% | |
ungroup() %>% | |
group_by(lat) %>% | |
arrange(lng) %>% | |
mutate(next.value = lead(value)) %>% | |
ggplot(aes(lng, lat + 5*(value/max(value)), xend=lng+0.1, yend=lat + 5*(next.value/max(value)))) + | |
geom_segment(size=0.4, alpha=0.8, color='#5A3E37') + | |
ggthemes::theme_map() + | |
coord_equal(0.9) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read_csv('GEOSTAT_grid_POP_1K_2011_V2_0_1.csv') %>% | |
rbind(read_csv('JRC-GHSL_AIT-grid-POP_1K_2011.csv') %>% | |
mutate(TOT_P_CON_DT='')) %>% | |
mutate(lat = as.numeric(gsub('.*N([0-9]+)[EW].*', '\\1', GRD_ID))/100, | |
lng = as.numeric(gsub('.*[EW]([0-9]+)', '\\1', GRD_ID)) * ifelse(gsub('.*([EW]).*', '\\1', GRD_ID) == 'W', -1, 1) / 100) %>% | |
filter(lng > 29, lng < 38) %>% | |
filter(lat > 30, lat < 42) %>% | |
group_by(lng=round(lng, 1), lat=round(lat, 1)) %>% | |
summarize(value = sum(TOT_P, na.rm=TRUE)) %>% | |
ungroup() %>% | |
group_by(lat) %>% | |
arrange(lng) %>% | |
mutate(next.value = lead(value)) %>% | |
ggplot(aes(lng, lat + 5*(value/max(value)), xend=lng+0.1, yend=lat + 5*(next.value/max(value)))) + | |
geom_segment(size=0.4, alpha=0.9, color='#5A3E37') + | |
ggthemes::theme_map() + | |
coord_equal(0.9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment