#30dayMapChallenge

CorrelCon

Alexandra Kapp

7th Nov 2020

What is the #30dayMapChallenge?

My submission to the challenge

  • ~ 15 days of the 30 days
  • today I will present 10 of the maps
  • (mostly) interactive maps with R
  • Frameworks for interactive maps:
    • Leaflet
    • Deck.gl (Package: mapdeck)

Leaflet

  • leading open-source JavaScript library
  • has been around for ~ 10 years
  • usually when you see maps online, they are made with Leaflet

Deck.gl

  • started ~ 4 years ago
  • especially great for large data and 3D views
  • R package to access deck.gl: mapdeck

Day 1

Points

plotting all + 80.000 cars in Friedrichshain-Kreuzberg

geocomputation made easy with the sf package

  • crop polygon to outline of another polygon
streets_in_xhain <- st::st_intersection(streets_berlin, xhain_outline) 
  • sample points in a polygon
cars <- st::st_sample(streets_xhain,size= 80808)

Day 8

Yellow

Plot raster data with leaflet and leafem

  • add raster data: leaflet::addRasterImage()
  • add Mouseover for raster data: leafem::addImageQuery()
leaflet() %>% 
    addProviderTiles(providers$CartoDB.DarkMatter) %>%
    addRasterImage(hours_of_sunshine, group = "g") %>% 
    addImageQuery(hours_of_sunshine, layerId = "g")

Day 3

Polygons

Which boulder gym is closest to you?

Create a geospatial voronoi map mit dismo

gyms_voronoi <- dismo::voronoi(boulder_gyms[c("lon", "lat")])

Day 14

Climate Change

How large is the area of in 2019 destroyed rain forest?

leafpm for editable polygons

  • leafpm::addPmToolbar() to draw, cut, edit and move vectors
  leaflet(rainforest_area) %>%
    addTiles() %>%
    addPolygons(group = "p") %>% 
    leafpm::addPmToolbar(targetGroup = "p")

Day 9

Monochrome

use stplanr for routing and aggregating lines

start_points <- st_sample(berlin,size=500) %>% st_as_sf
end_points <- st_sample(berlin,size=500) %>% st_as_sf

routes <- stplanr::route(from = start_points, 
                to = end_points, 
                route_fun = osrmRoute,
                returnclass = "sf")

routes["count"] <- 1

overlapping_segments <- stplanr::overline(routes, attrib = "count")

Day 20

Population

react to clicks on leaflet map with shiny

observeEvent(input$map_shape_click, {})

Backup image

Day 2

Lines

Air traffic between German Airports

Origin destination with flowmap.blue

  • Flowmap.blue
  • fast and easy viz of origin destination data
  • can be done entirely without coding (with Google Sheets)
  • new: also available as R package

Backup image

Day 10

Grid

get OSM data with osmdata

  • OpenStreetMap overs a huge ressource on openly available geodata (streets, rivers, restaurants, stores, … )
  • this data can be retrieved with the Overpass API which is accesible with the osmdata package in R
osmdata::opq(bbox = 'berlin germany') %>%
     add_osm_feature(key = 'amenity', 
                     value = c('fast_food', 'restaurant')) %>% 
     osmdata_sf ()

auto aggregated grids with mapdeck

  • insert point data
  • point counts are automatically aggregated to grids
mapdeck::mapdeck() %>% 
 mapdeck::add_screengrid(data = restaurants)

Backup image

Day 4

Hexagons

All traffic accidents in Stuttgart

elevation and hexagons with mapdeck

  • insert point data
  • point counts are automatically aggregated to hexagons
mapdeck::mapdeck() %>% 
 mapdeck::add_hexagon(data = accidents_stuttgart)

Backup image

Day 22

Movement

all U-Bahns in Berlin

moving lines with mapdeck

mapdeck::mapdeck() %>% 
 mapdeck::add_trips(data = ubahn)

Thanks for your attention!