knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(rPkgNOAADataset)

Earth quakes and Timeline

Let's investigate a few exmaple with the timeline functions give by the package

require(earthquakesWithR)
require(magrittr) # for piping operator
require(dplyr) # for filter/subsetting functions
require(ggplot2) # should be obvious :)
require(ggthemes) # for the theme_classic()

CentralEurope <- c("AUSTRIA", "GERMANY", "HUNGARY", "LIECHTENSTEIN", "POLAND", "SLOVENIA", "SWITZERLAND")

# Load the data and filter it accordingly to your needs
data("NOAAearthquakes")
quakes_CentEU <- NOAAearthquakes %>%
        filter(COUNTRY %in% CentralEurope & YEAR >= 0)

# single country without labels
ggplot() +
        geom_timeline(data = quakes_CentEU, aes(x = date, y = COUNTRY, color = TOTAL_DEATHS, size = EQ_PRIMARY)) +
        theme_classic()
Europe <- c("AZORES (PORTUGAL)", "ALBANIA", "ANDORRA", "AUSTRIA", "BELARUS", "BELGIUM", "BOSNIA-HERZEGOVINA", "BOSNIA", "HERZEGOVINA2", "BULGARIA", "CROATIA", "CYPRUS", "CZECH REPUBLIC", "DENMARK", "FINLAND", "FRANCE", "GEORGIA", "GEROMANY", "GREECE", "HUNGARY", "ICELAND", "IRELAND", "ITALY", "KOSOVO", "LIECHTENSTEIN", "LUXEMBOURG", "MACEDONIA", "MALTA", "MOLDOVA", "MONACO", "MONTENEGRO", "NETHERLANDS", "NORWAY", "POLAND", "PORTUGAL", "ROMANIA", "SAN MARINO", "SERBIA", "SERBIA AND MONTENEGRO", "SLOVAKIA", "SLOVENIA", "SPAIN", "SWEDEN", "SWITZERLAND", "TURKEY", "UKRAINE", "UK", "UK TERRITORY", "VATICAN CITY")
quakes_EU <- NOAAearthquakes %>%
        filter(COUNTRY %in% Europe & YEAR >= 0)

# single country without labels
ggplot() +
        geom_timeline(data = quakes_EU, aes(x = date, y = COUNTRY, color = TOTAL_DEATHS, size = EQ_PRIMARY)) +
        theme_classic()

ggplot() +
        geom_timeline(data = quakes_EU, aes(x = date, y = COUNTRY, color = TOTAL_DEATHS, size = EQ_PRIMARY)) +
        geom_timeline_label(data = quakes_EU, aes(x = date,
                                                 y = COUNTRY,
                                                 magnitude = EQ_PRIMARY,
                                                 label = LOCATION_NAME,
                                                 n_max = 1)) +
        theme_classic()
SouthAmerica <- c("ARGENTINA", "BOLIVIA", "BRAZIL", "CHILE", "COLOMBIA", "ECUADOR", "GUYANA", "PARAGUAY", "PERU", "SURINAME", "URUGUAY", "VENEZUELA")
quakes_SA <- NOAAearthquakes %>%
        filter(COUNTRY %in% SouthAmerica & YEAR >= 0)

# single country without labels
ggplot() +
        geom_timeline(data = quakes_SA, aes(x = date, y = COUNTRY, color = TOTAL_DEATHS, size = EQ_PRIMARY)) +
        theme_classic()


ggplot() +
        geom_timeline(data = quakes_SA, aes(x = date, y = COUNTRY, color = TOTAL_DEATHS, size = EQ_PRIMARY)) +
        geom_timeline_label(data = quakes_SA, aes(x = date,
                                                 y = COUNTRY,
                                                 magnitude = EQ_PRIMARY,
                                                 label = LOCATION_NAME,
                                                 n_max = 1)) +
        theme_classic()

Conclusion

As we have seen in the README.md, the timeline functions work very well for 1-3 countries. We see here, it works for multiple countries, too, however, the labeling should be improved on. We see that the labels are being cut off by the ggplot-object.
Now let's see what the leaflet map shows us for these subsets

Earth quakes and Leaflet map

We directly take the above defined subsets:
- earth quakes in Central Europe
- earth quakes in Europe
- earth quakes in South America

(!!) You'll see on the map that the countries are sourrended with a polygon. Please note that only countries which encountered and earth quake are marked with a polygon. If nothing happend, no polygon is shown.

Central Europe - A.D. until today

require(leaflet)

quakes_CentEU %>%
        dplyr::mutate(popup_text = eq_create_label(.)) %>%
        eq_map(annot_col = "popup_text")

Europe - 2010 until today

quakes_EU %>%
        dplyr::filter(lubridate::year(date) >= 2010) %>% # additional subset, or else too many points
        dplyr::mutate(popup_text = eq_create_label(.)) %>%
        eq_map(annot_col = "popup_text")

South America - 2010 until tolday

quakes_SA %>%
        dplyr::filter(lubridate::year(date) >= 2010) %>% # additional subset, or else too many points
        dplyr::mutate(popup_text = eq_create_label(.)) %>%
        eq_map(annot_col = "popup_text")

Conclusion

The leaflet maps work very well. Future work still can be done, for instance the circle representations of the earth quakes can be improved on (play around with transparency and size, etc.)



Brunobt80/rPkgNOAADataset documentation built on May 20, 2019, 12:57 a.m.