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.
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 with the use of an interactive map.
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
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 R packages
library(tidyverse)
library(cowplot)
library(RColorBrewer)
library(sf)
library(leaflet)
library(leaflet.extras)
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.
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.
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.