4/7/2020

Intro to Final Project

The idea for the Final Project was to use a animated map to present some data, I used some fictious data regarding the production of wine, beer and olive oil in 4 european countries

Data Overview

##     region               year           vino           birra      
##  Length:20          Min.   :2015   Min.   : 7.50   Min.   :11.00  
##  Class :character   1st Qu.:2016   1st Qu.:27.32   1st Qu.:15.75  
##  Mode  :character   Median :2017   Median :40.35   Median :24.50  
##                     Mean   :2017   Mean   :34.90   Mean   :37.85  
##                     3rd Qu.:2018   3rd Qu.:46.90   3rd Qu.:47.75  
##                     Max.   :2019   Max.   :54.10   Max.   :94.00  
##       olio               lng               ltd       
##  Min.   :   0.700   Min.   :-3.7038   Min.   :40.42  
##  1st Qu.:   3.525   1st Qu.: 0.8358   1st Qu.:41.53  
##  Median : 109.250   Median : 7.4226   Median :45.38  
##  Mean   : 427.365   Mean   : 6.1359   Mean   :45.92  
##  3rd Qu.: 514.000   3rd Qu.:12.7227   3rd Qu.:49.77  
##  Max.   :1678.000   Max.   :13.4023   Max.   :52.50

Data overview - table

Data in table visualization
region year vino birra olio lng ltd
Italy 2015 48.6 14 212.0 12.496126 41.90155
Italy 2016 51.6 11 234.0 12.496126 41.90155
Italy 2017 43.8 15 222.0 12.496126 41.90155
Italy 2018 54.1 13 274.0 12.496126 41.90155
Italy 2019 46.6 12 265.0 12.496126 41.90155
France 2015 47.8 16 5.1 2.349014 48.86472
France 2016 44.4 17 5.6 2.349014 48.86472
France 2017 36.8 22 4.3 2.349014 48.86472
France 2018 49.5 19 6.2 2.349014 48.86472
France 2019 41.9 21 6.5 2.349014 48.86472
Spain 2015 37.2 27 1678.0 -3.703790 40.41678
Spain 2016 38.8 29 1234.0 -3.703790 40.41678
Spain 2017 33.0 32 1365.0 -3.703790 40.41678
Spain 2018 44.9 34 1432.0 -3.703790 40.41678
Spain 2019 34.3 38 1599.0 -3.703790 40.41678
Germany 2015 8.9 94 0.8 13.402328 52.50141
Germany 2016 9.0 86 0.9 13.402328 52.50141
Germany 2017 7.5 92 0.7 13.402328 52.50141
Germany 2018 10.3 88 1.2 13.402328 52.50141
Germany 2019 9.0 77 1.0 13.402328 52.50141

Leaflet and addMinicharts

I have used a basic leaflet map as starting point and I have added minicharts on it that can be automatically updated In a separate script I have created it

# Create base map
tilesURL <- "http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/
World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}"

basemap <- leaflet(width = "100%", height = "400px") %>%
  addTiles(tilesURL) 

#Mini charts
leafletProxy("map", session) %>%
            updateMinicharts(
                eur$region,
                chartdata = data,
                maxValues = maxValue,
                time = eur$year,
                type = ifelse(length(input$prods) < 2,
                              "polar-area", input$type),
                showLabels = input$labels
            )