Created by the EPA, the Uranium Mines and Mills Location Database is comprised of information regarding known or potential mine and mill locations and mine features from federal, state, and Tribal agencies into a single database. More information can be found here.
In R, we need 3 packages to download and visualize the data. First, check if the packages are already installed. Install them if they are not:
packages <- c("tidyverse", "httr", "sf")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)>0) install.packages(new.packages)
Then, load them:
lapply(packages, library, character.only = TRUE)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.2 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.2 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Linking to GEOS 3.10.2, GDAL 3.4.2, PROJ 8.2.1; sf_use_s2() is TRUE
[[1]]
[1] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
[7] "tidyr" "tibble" "ggplot2" "tidyverse" "stats" "graphics"
[13] "grDevices" "utils" "datasets" "methods" "base"
[[2]]
[1] "httr" "lubridate" "forcats" "stringr" "dplyr" "purrr"
[7] "readr" "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
[13] "graphics" "grDevices" "utils" "datasets" "methods" "base"
[[3]]
[1] "sf" "httr" "lubridate" "forcats" "stringr" "dplyr"
[7] "purrr" "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
[13] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[19] "base"
Download the data set:
url <- "https://www.epa.gov/sites/default/files/2015-03/uld-ii_gis.zip"
Uranium <- GET(url)
data_file <- "Uranium_mines.zip"
writeBin(content(Uranium, "raw"), data_file)
# Unzip the file
unzip(data_file)
Read the data set:
mines <- st_read("Master_Database_and_Shape_Files/ULD_albers.shp")
Reading layer `ULD_albers' from data source
`/Users/ty/Documents/Github/data-library/docs/hazards/Uranium_mines/Master_Database_and_Shape_Files/ULD_albers.shp'
using driver `ESRI Shapefile'
Simple feature collection with 14810 features and 30 fields
Geometry type: MULTIPOINT
Dimension: XY
Bounding box: xmin: -3296195 ymin: -1542681 xmax: 1955673 ymax: 4183792
Projected CRS: North_America_Albers_Equal_Area_Conic
Calculate number of mines per county in Colorado:
mines_co <- mines %>%
filter(STATE_NAME %in% 'Colorado') %>%
group_by(COUNTY_NAM) %>%
summarise(mines = n())
And plot them (top ten):
mines_co <- mines_co[order(-mines_co$mines),][1:10,] %>%
mutate(COUNTY_NAM = factor(COUNTY_NAM))
ggplot(mines_co) +
geom_bar(aes(y = fct_reorder(COUNTY_NAM, mines), x = mines), stat = "identity") +
xlab("Number of Uranium mines") +
ylab("") +
theme_bw() +
ggtitle("Top 10 counties with Uranium mines in Colorado")
In Python, we need 4 libraries to download and visualize the data. You can find data definitions and sources here.
import requests
import zipfile
import geopandas as gpd
import matplotlib.pyplot as plt
Download the data set:
# download file
url = "https://www.epa.gov/sites/default/files/2015-03/uld-ii_gis.zip"
response = requests.get(url)
# save to file
data_file = "Uranium_mines.zip"
with open(data_file, 'wb') as f:
f.write(response.content)
# unzip file
222483119
with zipfile.ZipFile(data_file, 'r') as zip_ref:
zip_ref.extractall('.')
Read the data set:
mines = gpd.read_file("Master_Database_and_Shape_Files/ULD_albers.shp")
Calculate number of mines per county in Colorado:
mines_co = (
mines
.loc[mines['STATE_NAME'] == 'Colorado']
.groupby('COUNTY_NAM')
.agg(mines=('COUNTY_NAM', 'size'))
)
And plot them (top ten):
mines_co = mines_co.sort_values('mines', ascending=False).iloc[:10]
plt.barh(y=mines_co.index, width=mines_co['mines'])
<BarContainer object of 10 artists>
plt.xlabel('Number of Uranium mines')
plt.ylabel('County')
plt.title('Top 10 counties with Uranium mines in Colorado')
plt.gca().invert_yaxis()
plt.show()