Spatial Data Visualization

A short description of the post.

Marie true
03-01-2021

California Oil Spills

Figure 1. Interactive Map in tmap.

hide
#---------------------------------------
# Make interactive map with tmap
#---------------------------------------

tmap_mode("view")

tm_basemap("Stamen.TerrainBackground") +
tm_shape(oil_spills) +
  tm_dots(col = "red", legend.show = FALSE) +
  tm_layout(title = "Oil spill locations and dates in California")

California oil spill locations shown in red, hover to show date.


Figure 2. Chloreopleth Map in ggplot.

hide
#---------------------------------------
# Make choropleth map with ggplot
#---------------------------------------

# Spatial join and calculate number of spills per county
ca_spills <- st_join(ca_counties, oil_spills) %>% 
  group_by(name) %>%
  summarize(
    counts = n()
  )

# Plot
ggplot() +
  geom_sf(data = ca_spills, aes(fill = counts)) +
  labs(fill = "Number of oil spills") +
  scale_fill_gradient(low = "#F9C48B", high = "#F25C54") +
  labs(title = "Number of oil spills per county in California") +
  theme_void()


Counties with the highest number of oil spill incidents are shown in orange and counties with the lowest overall incidents are shown in pale yellow.


Data source: Title Oil Spill Incident Tracking [ds394] Publication date 2009-07-23. Edition 2008. Presentation formats digital map. FGDC geospatial presentation format vector digital data. Available at: