Introduction

This document consists of two major sections. First, we are going to analyze and visualize tornado activity within Oklahoma over a specified period of time. Through a combination of mapping and data visualization techniques, this project aims to provide insights into the patterns and density of tornado occurrences, their paths, and how these aspects vary across different regions and over time. In section two, this project will provide an overview of mineral mining facilities throughout the African continent with the use of an interactive map.

Load Library Packages

The first step for this analysis is to load the library packages that will be used throughout the process. The packages are:

tidyverse = Includes the packages that are use in everyday data analyses, such as ggplot2, dplyr, and readr to name a few. Additional details can be found at This Site

cowplot = The cowplot package provides various features that help with creating publication-quality figures, such as a set of themes, functions to align plots and arrange them into complex compound figures, and functions that make it easy to annotate plots and or mix plots with images. Additional details can be found at This Site

RColorBrewer = Provides color schemes for maps (and other graphics) designed by Cynthia Brewer. Additionalinformation on this package can be found at This Site

sf =Support for simple features, a standardized way to encode spatial vector data. Additional information can be located at This Site

# Load necessary R packages

library(tidyverse)
library(cowplot)
library(RColorBrewer)
library(sf)

Section 1- Oklahoma Tornado Mapping

For this section, we will examine tornado activity in Oklahoma with a various geospatial data sets which cover 67 years of reporting. First, we will generate a map of tornado paths where the paths from each year are displayed as a different color, and create a composite figure containing the map of tornado paths and the map of tornado points. Next, we will summarize the density of tornado points by both county and year and generate a faceted plot that displays maps of county-level tornado density from 2016-2021.And finally, we will generate four choropleth maps of tornado density based on quantile breaks with numbers of classes ranging from 3 to 6, and create a composite figure containing the four maps to examine how the number of classes changes the interpretation of the map.

Data Overview

The data that we will be using for this project consist of three shapefile

Oklahoma Counties = This shapefile contains the geometry (borders) of counties in Oklahoma.

Oklahoma Tornado Paths = This shapefile outlines the paths taken by tornadoes, including start and end points, and the path in between.

Oklahoma Tornado Points = This shapefile represents the reported locations of tornado occurrences, such as points of touchdown or points of significant events along the tornado’s path.

Data Loading

For the analysis in section 1, we will load the data that will be used for all three analysis in section 1 to simplify the process.

# Read the datasets

ok_counties <- st_read("ok_counties.shp", quiet = TRUE)
tornado_points <- st_read("ok_tornado_point.shp", quiet = TRUE)
tornado_paths <- st_read("ok_tornado_path.shp", quiet = TRUE)

Analysis

1. Generate a Composit Map of Tornado Paths and Points for All Years Reported

First, we ill generate the map for the reported tornado paths broken down by year.

# Generate the map for tornado paths colored by year

tornado_paths_map <- ggplot() +
  geom_sf(data = ok_counties, fill = NA, color = "grey") +
  geom_sf(data = tornado_paths, aes(color = as.factor(yr)), size = 1) +
  scale_color_viridis_d(name = "Year") +
  theme_minimal() +
  theme(legend.position = "right")

# Display the Tornado Paths plot

tornado_paths_map

And next, generate the map for the reported tornado paths broken down by year.

# Generate the map for tornado points

tornado_points_map <- ggplot() +
  geom_sf(data = ok_counties, fill = NA, color = "grey") +
  geom_sf(data = tornado_points, aes(color = as.factor(yr))) +
  scale_color_viridis_d(name = "Year") +
  theme_minimal() +
  theme(legend.position = "right")

# Display the Tornado Points  plot

tornado_points_map


And finally, a composite of the two products.

# Create a composite figure

composite_figure <- plot_grid(tornado_paths_map, tornado_points_map, 
                              labels = c("Reported Tornado Paths", "Reported Tornado Points"), 
                              ncol = 1, 
                              align = "v")

# Display the composite figure plot

composite_figure


2. Summarize The Density of Tornado Points by Both County and Year

Next, we are going to take Summarize the density of tornado points by both county and year. Then, generate a faceted plot that displays maps of county-level tornado density from 2016-2021.

As seen in the previous analysis, there is 67 years of reported data. When displaying all of the data, the product is cluttered and hard to read. For this analysis, let’s apply a filter of the data to only encompass the years 2016-2021.

# Filter tornado data for years 2016-2021

tpoint_filtered <- tornado_points  %>%
  filter(yr >= 2016 & yr <= 2021)

Next, a spatial join needs to be performed in order of the tornado points and the Oklahoma County datasets.

# Perform a spatial join of tornado points to counties

tornado_county_join <- st_join(tpoint_filtered, ok_counties, join = st_within)

# Drop geometry for non-spatial operations

tornado_county_no_geom <- st_drop_geometry(tornado_county_join)

# Summarize tornado counts by COUNTYFP and year

tornado_summary <- tornado_county_no_geom %>%
  group_by(COUNTYFP, yr) %>%
  summarize(tornado_count = n(), .groups = 'drop')

# Join summary back to counties

ok_counties_unique <- ok_counties %>%
  select(COUNTYFP, geometry) %>%
  distinct()

# Perform a spatial join 

county_tornado_summary <- merge(ok_counties_unique, tornado_summary, by = "COUNTYFP")

After the spatial join succeeded, next we need to calculate the square kilometers of each county.

# Calculate the area of each county in square kilometers

county_tornado_summary$area_km2 <- st_area(county_tornado_summary) / 10^6

Next, we are going to summarize the count of tornadoes within each county to get the density of tornados in each county.

# Ensuring there is a tornado count for each county-year combination

county_tornado_summary <- county_tornado_summary %>%
  group_by(COUNTYFP) %>%
  mutate(tornado_density_km2 = ifelse(is.na(tornado_count), 0, tornado_count / area_km2 * 1000)) %>%
  ungroup()

And finally, it is time to create the composite plot of County-Level Tornado Density in Oklahoma (2016-2021).

# Creating the faceted plot

ggplot(data = county_tornado_summary) +
  geom_sf(aes(fill = tornado_density_km2)) +
  facet_wrap(~ yr, ncol = 3) +
  scale_fill_viridis_c(option = "viridis", direction = 1, name = "Tornado Density\n(per 1000 km²)") +
  labs(title = "County-Level Tornado Density in Oklahoma (2016-2021)", 
       subtitle = "Faceted by Year") +
  theme_minimal() +
  theme(legend.position = "bottom", 
        strip.background = element_blank(),
        strip.text.x = element_text(size = 10, angle = 0, hjust = 0.5))

3. Generate Four Choropleth Maps of Tornado Density Based on Quantile Breaks

This analysis combines spatial data manipulation with visualization techniques to provide insights into how tornado occurrences are distributed by density across counties, emphasizing the impact of different classification schemes on the perception of data.

First, we need to make sure the Oklahoma Counties data we are using has valid geometries for the spatial join that needs to occur.

# Making sure 'ok_counties_sf' has valid geometries

ok_counties_sf <- st_make_valid(ok_counties)

After verification of the geometries, it is time to perfom the spatial join between the tornado point data and the Oklahoma Counties data.

# Performing a spatial join to attribute tornado points to counties

tornado_in_county <- st_join(tornado_points, ok_counties_sf, join = st_within)

Next, we need to aggregate the tornado data in each county. This aggregation not only quantifies the tornado activity within each county but also prepares us for merging these insights back into our county dataset.

# Aggregating tornado counts by county

tornado_count <- tornado_in_county %>%
  group_by(COUNTYFP) %>%
  summarise(tornado_count = n(), .groups = 'drop')

After the aggregation of the data, we prepare our county dataset for merging by ensuring compatible data types. Following a successful merge with the tornado counts, we re-infuse the spatial geometry into our enriched dataset.

# Preparing 'ok_counties_sf' for merging

ok_counties_sf$COUNTYFP <- as.character(ok_counties_sf$COUNTYFP)

# Merge tornado counts back into county data then dropping geometry for the merge and rejoining later ensures no logical vector issue

ok_counties_sf_no_geom <- st_drop_geometry(ok_counties_sf)
ok_counties_merged <- left_join(ok_counties_sf_no_geom, tornado_count, by = "COUNTYFP")

# Adding geometry back to the merged data frame

ok_counties_merged <- st_as_sf(ok_counties_merged, geometry = st_geometry(ok_counties_sf), crs = st_crs(ok_counties_sf))

Now the merge of the data is complete, it is time to start examining tornado density. By calculating the area of each county and the corresponding tornado density, we transform raw counts into meaningful metrics that reflect the spatial extent of tornado occurrences per unit area.

# Calculating area in square kilometers

ok_counties_merged$area_km2 <- as.numeric(st_area(ok_counties_merged)) / 10^6

# Calculating tornado density per 1000 km square and handling NA values from counties without tornadoes

ok_counties_merged$tornado_density <- with(ok_counties_merged, ifelse(is.na(tornado_count), 0, tornado_count) / area_km2 * 1000)

Now that the calculations are complete, it is time to display the data into a series of choropleth maps, each visualizing tornado density with different classification schemes. These maps, ranging from three to six classes, are not mere representations of data; they are a visual exploration of how classification impacts our perception of tornado risk across Oklahoma.

# Generating maps with corrected area and tornado density calculations

plots <- list()
for (num_classes in 3:6) {
  ok_counties_merged$tdens_class <- cut_number(ok_counties_merged$tornado_density, n = num_classes, labels = FALSE)
  
  p <- ggplot(data = ok_counties_merged) +
    geom_sf(aes(fill = factor(tdens_class)), color = "white") +
    scale_fill_brewer(palette = "YlOrRd", name = "Tornado Density\n(Per 1000 km²)") +
    labs(title = paste("Tornado Density with", num_classes, "Classes")) +
    theme_minimal() +
    theme(legend.position = "bottom")
  
  plots[[num_classes-2]] <- p # Adjust index for list
}

# Creating composite figure to display

composite_map <- plot_grid(plotlist = plots, ncol = 2)

# Displaying map

print(composite_map)

This visualization brings together the separate threads of our analysis, presenting a cohesive and comparative view of tornado density across Oklahoma counties.

Conclusion of Section 1

We have undertaken a comprehensive analysis of tornado activity within Oklahoma, leveraging an extensive dataset that spans 67 years. This investigation commenced with the generation of distinct maps delineating the paths and points of reported tornadoes, each differentiated by color to signify the year of occurrence. Aiming to shed light on the patterns and densities of these natural phenomena, we meticulously compiled a composite figure that merges the visual representations of both tornado paths and points. Delving deeper, we applied a focused lens on the years 2016 to 2021, summarizing tornado point density across counties to produce a faceted plot that vividly illustrates the distribution of tornadoes during this period. Our analytical journey further led us to create four choropleth maps, each categorized by different quantile breaks ranging from 3 to 6 classes. This approach not only highlights the spatial variability of tornado density across Oklahoma but also invites contemplation on how varying classification schemes influence the interpretation of such data. Through these methodical steps, this section not only aims to enhance our understanding of tornado activity’s spatial dynamics but also sets a precedent for employing sophisticated mapping and data visualization techniques in environmental analysis. In section 2, we will explore mining facility data and create an interactive map using the leaflet package.

Section 2 - Mining Opeartions Throughout The African Continant.

The critical role of mineral resources in the advancement and sustainability of modern technology is challenging to overstate. These resources, ranging from rare earth elements used in electronics and renewable energy technologies to precious metals like gold and diamonds, form the foundation of various industries that drive the global economy. Africa, with its vast and diverse mineral wealth, stands at the forefront of this narrative. The continent’s abundant reserves of minerals such as cobalt, diamond, gold, and platinum make it a key player in the global supply chain, contributing significantly to technological innovation and economic development.

For this section, we will utilize the leaflet package to create an interactive map which show where the mining facilities are located at within the African continent giving users the ability to not only see where the facilities are located at, but also see what resources the facility is extracting.

Load Library Packages

While some of the packages have already been loaded into the project, there are two additional packages that are needed to create the interactive map. Those packages are:

leaflet = Is used to create interactive web maps with the JavaScript ‘Leaflet’ Library. Additional details can be found at This Site

leaflet.extras = This package serves as an add-on to the ‘leaflet’ package by providing extra functionality via ‘leaflet’ plugins. Additional details can be found at This Site

# Load necessary libraries

library(leaflet)
library(leaflet.extras)

Data Overview

The data we are using to display on a web map is the mineral production and processing facilities data layer from the U.S. Geological Survey’s (USGS) Compilation of Geospatial Data (GIS) for the Mineral Industries and Related Infrastructure of Africa. Website The data consists of mining facility locations, the type of mining operations, the commodity being extracted, and the annual output to name a few.

Let’s load the mining facility data and examine the attribute information.

# Read the shapefile

shapefile_path <- "MiningFacilities.shp.zip"

mining_facilities <- st_read(shapefile_path)
## Reading layer `MiningFacilities' from data source 
##   `E:\PSU\GEOG 588 Analytical Approaches in Spatial Data Science\R-Studio Labs\Lesson 4\MiningFacilities.shp.zip' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 2408 features and 29 fields
## Geometry type: POINT
## Dimension:     XYZ
## Bounding box:  xmin: -23.72795 ymin: -35.30673 xmax: 57.6109 ymax: 37.26486
## z_range:       zmin: 0 zmax: 0
## Geodetic CRS:  WGS 84
# Inspect the dataset structure to understand the variables

print(head(mining_facilities))
## Simple feature collection with 6 features and 29 fields
## Geometry type: POINT
## Dimension:     XYZ
## Bounding box:  xmin: -0.379742 ymin: 27.83072 xmax: 9.533611 ymax: 36.67373
## z_range:       zmin: 0 zmax: 0
## Geodetic CRS:  WGS 84
##   FeatureUID Label1 Country                    FeatureNam         FeatureTyp
## 1     DZA001   DZA1 Algeria           Achab-Draa oilfield Oil and Gas Fields
## 2     DZA002   DZA2 Algeria   Aggregate quarries at Adrar Mines and Quarries
## 3     DZA003   DZA3 Algeria   Aggregate quarries at Arzew Mines and Quarries
## 4     DZA004   DZA4 Algeria  Aggregate quarries at Ghedir Mines and Quarries
## 5     DZA005   DZA5 Algeria  Aggregate quarries at Gustar Mines and Quarries
## 6     DZA006   DZA6 Algeria Aggregate quarries at Keddara Mines and Quarries
##    DsgAttr01 DsgAttr02   DsgAttr03 DsgAttr04 DsgAttr05 DsgAttr06
## 1       Fuel Petroleum       Crude         N         N      2018
## 2 Industrial     Stone Unspecified         N         N      2018
## 3 Industrial     Stone Unspecified         N         N      2018
## 4 Industrial     Stone Unspecified         N         N      2018
## 5 Industrial     Stone Unspecified         N         N      2018
## 6 Industrial     Stone Unspecified         N         N      2018
##                   DsgAttr08 DsgAttr09      LocOpStat
## 1 42-gallon barrels per day         c Assumed Active
## 2               Metric tons         c Assumed Active
## 3               Metric tons         c Assumed Active
## 4               Metric tons         c Assumed Active
## 5               Metric tons         c Assumed Active
## 6               Metric tons         c Assumed Active
##                                                                                                                                                                                                                                                        MemoOther
## 1 Capacity is a combination of about 50 oilfields, including Acheb; West, Amassak/Tin-Yaguene, Draa; Tamra, Edjeleh, El Borma, El Gassi; Gassi-Touil East, Guellala; Hassi Messaoud North and South; Ohanet North, Rhourde El Baguel; Tin-Fouye Tabankort, and Z
## 2                                                                                                                      Capacity is a combination of aggregate quarries at Adrad, Oufarnou, Arzew, Ghedir, Gustar, Keddara, Oued Fodda, Tadjertila, and Timezrit.
## 3                                                                                                                      Capacity is a combination of aggregate quarries at Adrad, Oufarnou, Arzew, Ghedir, Gustar, Keddara, Oued Fodda, Tadjertila, and Timezrit.
## 4                                                                                                                      Capacity is a combination of aggregate quarries at Adrad, Oufarnou, Arzew, Ghedir, Gustar, Keddara, Oued Fodda, Tadjertila, and Timezrit.
## 5                                                                                                                      Capacity is a combination of aggregate quarries at Adrad, Oufarnou, Arzew, Ghedir, Gustar, Keddara, Oued Fodda, Tadjertila, and Timezrit.
## 6                                                                                                                      Capacity is a combination of aggregate quarries at Adrad, Oufarnou, Arzew, Ghedir, Gustar, Keddara, Oued Fodda, Tadjertila, and Timezrit.
##                                                                                DsgAttr10
## 1 DZA022, DZA023, DZA024, DZA035, DZA045, DZA046, DZA078, DZA106, DZA113, DZA114, DZA117
## 2                         DZA004, DZA005, DZA006, DZA007, DZA008, DZA009, DZA010, DZA011
## 3                         DZA003, DZA005, DZA006, DZA007, DZA008, DZA009, DZA010, DZA011
## 4                         DZA003, DZA004, DZA006, DZA007, DZA008, DZA009, DZA010, DZA011
## 5                         DZA003, DZA004, DZA005, DZA007, DZA008, DZA009, DZA010, DZA011
## 6                         DZA003, DZA004, DZA005, DZA006, DZA008, DZA009, DZA010, DZA011
##   MemoLoc Latitude Longitude LocConfid   LocSource1
## 1  <null> 28.03530  9.533611         A Google Earth
## 2   Adrar 27.83072 -0.347712         A Google Earth
## 3   Arzew 35.85657 -0.379742         A Google Earth
## 4  Ghedir 36.67373  6.960445         A Google Earth
## 5  Gustar 36.00794  5.551643         A Google Earth
## 6 Keddara 36.62616  3.509204         A Google Earth
##                                                                                                                                                                InfSource1
## 1 USGS 2018 Minerals Yearbook, Vol. III, Algeria Country Chapter, Table 2; various other USGS, industry, geologic research, and company reports; various mining databases
## 2 USGS 2018 Minerals Yearbook, Vol. III, Algeria Country Chapter, Table 2; various other USGS, industry, geologic research, and company reports; various mining databases
## 3 USGS 2018 Minerals Yearbook, Vol. III, Algeria Country Chapter, Table 2; various other USGS, industry, geologic research, and company reports; various mining databases
## 4 USGS 2018 Minerals Yearbook, Vol. III, Algeria Country Chapter, Table 2; various other USGS, industry, geologic research, and company reports; various mining databases
## 5 USGS 2018 Minerals Yearbook, Vol. III, Algeria Country Chapter, Table 2; various other USGS, industry, geologic research, and company reports; various mining databases
## 6 USGS 2018 Minerals Yearbook, Vol. III, Algeria Country Chapter, Table 2; various other USGS, industry, geologic research, and company reports; various mining databases
##                                         OperateNam
## 1                                 Sonatrach S.p.A.
## 2 Société Algérienne des Granulats S.p.A. (ALGRAN)
## 3 Société Algérienne des Granulats S.p.A. (ALGRAN)
## 4 Société Algérienne des Granulats S.p.A. (ALGRAN)
## 5 Société Algérienne des Granulats S.p.A. (ALGRAN)
## 6 Société Algérienne des Granulats S.p.A. (ALGRAN)
##                                                                                            OwnerName1
## 1                                                                                              <null>
## 2 Entreprise Nationale des Produits Miniers Non Ferreux et des Substances Utiles S.p.A. (ENOF) [100%]
## 3 Entreprise Nationale des Produits Miniers Non Ferreux et des Substances Utiles S.p.A. (ENOF) [100%]
## 4 Entreprise Nationale des Produits Miniers Non Ferreux et des Substances Utiles S.p.A. (ENOF) [100%]
## 5 Entreprise Nationale des Produits Miniers Non Ferreux et des Substances Utiles S.p.A. (ENOF) [100%]
## 6 Entreprise Nationale des Produits Miniers Non Ferreux et des Substances Utiles S.p.A. (ENOF) [100%]
##   OwnerName2 OwnerName3 OwnerName4      ADM1 DsgAttr07
## 1     <null>     <null>     <null>    Illizi   1700000
## 2     <null>     <null>     <null>     Adrar   3000000
## 3     <null>     <null>     <null>      Oran   3000000
## 4     <null>     <null>     <null>    Skikda   3000000
## 5     <null>     <null>     <null>     Sétif   3000000
## 6     <null>     <null>     <null> Boumerdès   3000000
##                         geometry
## 1   POINT Z (9.533611 28.0353 0)
## 2 POINT Z (-0.347712 27.83072 0)
## 3 POINT Z (-0.379742 35.85657 0)
## 4  POINT Z (6.960445 36.67373 0)
## 5  POINT Z (5.551643 36.00794 0)
## 6  POINT Z (3.509204 36.62616 0)

It is important to know what attribute provides what information for the web map. For example, while it is simple enough to know that “FeatureNam” is the name of the facility, without taking a look at the header information, we would not have known that “DsgAttrib02” contains the type of commodity the facility is extracting.

Now that we have examined the data, let’s start building a web map to display the information.

Web Map Creation

As there are multiple types of facilities, we should apply a color scheme to differentiate the various facilities. To do that, we will use the RColorBrewer packages to apply the “Dark2” color palette.

# Create a color palette for the types of mining facilities

color_palette <- colorFactor(palette = brewer.pal(5, "Dark2"), domain = mining_facilities$FeatureTyp)

# Display the color palette chosen

display.brewer.pal(n = 5, name = "Dark2")

Now it is time to build the map. To do this, we will use the leaflet package to build the map by using the Esri World Gray Canvas map background, and zoom to and center on the African continent for the initial view.

# Initialize leaflet map with a view centered on the mining facilities

map <- leaflet(mining_facilities) %>%
  
  addProviderTiles(providers$Esri.WorldGrayCanvas) %>%  # Adding the Esri World Gray Canvas base layer as the initial map layer
  
  setView(lat = 0, lng = 20, zoom = 4)                  # Setting the initial map view extent

map # display the map at this stage of creation

Next, we need to import the mining facilities data file. As there are over 2,400 features, we are going to create clustered circle markers for the facilities to present a clean view vs seeing 2,400 points on the map. We will also create a pop up of information for when the user clicks on a point. The pop up will provide the name of the facility, the type of of facility, the production volume, and the mineral that is being extracted. We will also add a lable pop up when the user puts thier cursour over the feature to the the name of the facility.

# Convert mining facilities to a simple feature collection for clustering

mining_facilities_sf <- st_as_sf(mining_facilities, coords = c("Longitude", "Latitude"), crs = 4326)

# Add mining facilities as clustered circle markers

map <- map %>%
  addCircleMarkers(data = mining_facilities_sf, 
                   
                   color = ~color_palette(FeatureTyp),
                   
                   fillOpacity = 1, # Adjust this value for desired opacity
                   
                   radius = 5,      # Adjust the size of the circle radius for the desired size on the map 
                   
                   popup = ~paste("<strong>Name:</strong>", FeatureNam, 
                                  "<br><strong>Type:</strong>", FeatureTyp, 
                                  "<br><strong>Production Volume:</strong>", DsgAttr07, " " , DsgAttr08,
                                  "<br><strong>Mineral Type:</strong>", DsgAttr02),
                   
                   label = ~paste(FeatureNam, "-", FeatureTyp), # Adding labels to the features for initial identification when the cursor is over the feature
                   
                   clusterOptions = markerClusterOptions(spiderfyOnMaxZoom = FALSE)) # Sets the point clustering effects. In this case, turns off the 

map # display the map at this stage of creation

Now that the data is loaded and the map is created, let’s add some tools to the map, such as a legend, additional map backgrounds, a mini map for a dynamic location diagram, and a scale bar.

# Add a legend to the map
 
map <- map %>%
  addLegend("bottomleft", 
            pal = color_palette, 
            values = ~FeatureTyp, 
            title = "Type of Mining Facility", 
            opacity = 1)

# Uses Leaflet’s built-in layers control you can choose one of base layers included into the project

map <- map %>%
  
  addProviderTiles(providers$Esri.WorldGrayCanvas, group = "Grayscale") %>%   # This web map provides a detailed vector basemap for the world featuring a neutral                                                                                  background style with minimal colors, labels, and features.
  
  addProviderTiles(providers$Esri.WorldTopoMap, group = "Topographic") %>%    # This web map provides a detailed vector basemap for the world featuring a classic                                                                                  Esri topographic map style including a relief map.
  
  addProviderTiles(providers$Esri.WorldImagery, group = "Imagery") %>%        # This web map features satellite imagery for the world and high-resolution aerial                                                                                   imagery for many areas. 
  
  addLayersControl (baseGroups = c("Grayscale", "Topographic", "Imagery"))

# Add a mini map

map <- map %>%
  addTiles(providers$Esri.WorldTopoMap) %>%        # Ensure the main map has a base layer
  addMiniMap(tiles = providers$Esri.WorldTopoMap,  # Base layer for the mini map
             width = 150, height = 150,            # Adjust size as needed
             toggleDisplay = TRUE)                 # Allows users to toggle the mini map

# Adding a scale bar to the map, both imperial and metric measurements

map <- map %>%
  addScaleBar(position = "bottomright", 
              options = scaleBarOptions(imperial = TRUE, metric = TRUE))

# Print the map to display the final result

map

And now, we have a completed web map to explore the mining facilities within the African continent. Take some time and explore the map, zoom into a clust, or double click it, to get information of the various mining operations. To get even more fidelity, when you zoom it, move your cursor the upper right hand and change the basemap to either Topographic to have a better idea of the surrounding area, or Imagery to the facility itself.

Section 2 Conclusion

By integrating the comprehensive dataset from the U.S. Geological Survey with the dynamic visualization capabilities of R, this section provided a window into the African continent’s rich mineral wealth. The interactive map serves as a tool, enabling users to visually navigate and understand the vast landscape of mining operations. Each facility is marked by distinct colors to differentiate their operational focus, enriched with pop-up information that provides insights into the facility’s name, type, production volume, and extracted mineral type.