Map 6: UCSB Main Campus

Detailed base map of the UCSB main campus using the visualization style of Map 1

Rendered Map Plate

Map 6 UCSB Main Campus

Map 6: UCSB main campus base map

Technical Summary

  • Objective: Provide a focused, high-detail coastal base map of UCSB’s main campus, designed using the visualization style of Map 1 and optimized to sit as the bottom hero panel of the composite Map 7 atlas plate.
  • Key Packages: terra, sf, ggplot2, dplyr
  • Data Sources:
    • Campus DEM (source_data/campus_DEM.tif)
    • Campus bathymetry (output_data/campus_bath_epsg2874.tif)
    • Campus hillshade (source_data/campus_hillshade.tif)
    • Campus buildings footprint (source_data/campus_buildings/Campus_Buildings.shp)
    • Isla Vista building structures (source_data/iv_buildings/iv_buildings/CA_Structures_ExportFeatures.shp)
    • Bike path centerlines (source_data/icm_bikes/bike_paths/bikelanescollapsedv8.shp)
    • NCOS Shorebird Foraging Habitat polygons (source_data/NCOS_Shorebird_Foraging_Habitat/)
    • NCOS Multi-use Trails (source_data/ncos_trails/ncos_multiuse_trails.geojson)
  • Aspect Ratio: 12 inches wide x 4 inches tall (3600 x 1200 px at 300 ppi) matching the Map 7 row 2 hero slot.

Step-by-Step Cartographic Workflow & Intermediate Outputs

The script scripts/map_06.r tightens the geographic extents of Map 1 to create an ultra-wide panoramic foundation map.

Step 1: Ingesting Vectors & Harmonizing Projections

The vector layers for buildings, bikeways, habitats, and Isla Vista structures are reprojected using st_transform to match the native projection of campus_DEM.tif (EPSG:2874 - NAD83 / California zone 5 (ftUS)).

# Align vector layers to DEM CRS
campus_projection <- crs(campus_DEM)
campus_bath <- project(campus_bath, campus_projection)
campus_hillshade <- project(campus_hillshade, campus_projection)
buildings <- st_transform(buildings, campus_projection)
bikeways <- st_transform(bikeways, campus_projection)
habitat <- st_transform(habitat, campus_projection)

Step 2: Intermediate Plot — Vector Alignment & Minimalist Graticule

Before adding the heavy raster stack, the script validates vector positions using a test plot styled with the custom rAtlas_theme.

# Intermediate vector layer test plot
ggplot() +
  geom_sf(data = habitat) +
  geom_sf(data = buildings) +
  geom_sf(data = iv_buildings) +
  geom_sf(data = bikeways) +
  theme(rAtlas_theme) +
  coord_sf()

Step 3: Cropping Rasters to Main Campus Extents & Map 1 Visualization

The digital elevation model, bathymetry, and hillshade rasters are tightly cropped to the main campus bounding extent:

# Crop all 3 raster inputs to the main campus bounding extent
main_campus_extent <- ext(5998500, 6008500, 1973500, 1982500)
campus_DEM_crop <- crop(campus_DEM, main_campus_extent)
campus_bath_crop <- crop(campus_bath, main_campus_extent)
campus_hillshade_crop <- crop(campus_hillshade, main_campus_extent)

Finally, the raster surfaces and vector layers are composited into a panoramic layout matching the visualization style of Map 1:

# Render main campus base map with Map 1 styling
final_map6 <- ggplot() +
  geom_raster(data = campus_DEM_df, aes(x = x, y = y, fill = elevation)) +
  geom_raster(data = campus_hillshade_df, aes(x = x, y = y, alpha = hillshade), show.legend = FALSE) +
  geom_raster(data = campus_bath_df, aes(x = x, y = y, fill = bathymetry)) +
  scale_fill_viridis_c(na.value = "NA", guide = guide_legend("bathymetry / elevation (US ft)")) +
  scale_alpha(range = c(0.05, 0.4), guide = "none") +
  geom_sf(data = iv_buildings, color = alpha("light gray", 0.15), fill = NA) +
  geom_sf(data = buildings, color = "pink", fill = alpha("pink", 0.3)) +
  geom_sf(data = habitat, color = alpha("darkorchid1", 0.3), fill = alpha("darkorchid1", 0.1)) +
  geom_sf(data = bikeways, color = "#00abff", linewidth = 0.8) +
  geom_sf(data = ncos_trails, color = "#00abff", linewidth = 0.8) +
  coord_sf(
    xlim = c(main_campus_extent$xmin, main_campus_extent$xmax),
    ylim = c(main_campus_extent$ymin, main_campus_extent$ymax),
    expand = FALSE
  ) +
  labs(
    title = "Map 6: UCSB Main Campus",
    subtitle = "Main campus buildings, environs, bikepaths",
    caption = "rAtlas Map 6"
  ) +
  rAtlas_theme +
  theme(
    plot.title = element_text(size = 18, face = "bold", hjust = 0),
    plot.subtitle = element_text(size = 13, hjust = 0),
    legend.position = "bottom"
  )

Map 6 Panoramic Output

Intermediate Output: Main campus base map saved to images/map6.1.png

Full R Script (scripts/map_06.r)

Show R Code
# map 6
# an alternate to map 1
# for the bottom of the page on map 7


library(terra)
library(ggplot2)
library(dplyr)
# library(raster)
library(sf)

# clean the environment and hidden objects
rm(list = ls())

# set map number
current_sheet <- 6
# set ggplot counter
current_ggplot <- 0

# make our ggtitles automagically #######
gg_labelmaker <- function(plot_num) {
  gg_title <- c("Map:", current_sheet, " ggplot:", plot_num)
  plot_text <- paste(gg_title, collapse = " ")
  print(plot_text)
  current_ggplot <<- plot_num
  return(plot_text)
}
# every ggtitle should be:
# ggtitle(gg_labelmaker(current_ggplot+1))
# end automagic ggtitle           #######

# vector layers
buildings <- st_read("source_data/campus_buildings/Campus_Buildings.shp")
bikeways <- st_read("source_data/icm_bikes/bike_paths/bikelanescollapsedv8.shp")
habitat <- st_read("source_data/NCOS_Shorebird_Foraging_Habitat/NCOS_Shorebird_Foraging_Habitat.shp")
iv_buildings <- st_read("source_data/iv_buildings/iv_buildings/CA_Structures_ExportFeatures.shp")
ncos_trails <- st_read("source_data/ncos_trails/ncos_multiuse_trails.geojson")

# rasters
# the background setup is bathymetry and topography mashed together
# this is worked through in map_01.r
# but we crop to just the main campus

campus_DEM <- rast("source_data/campus_DEM.tif")
campus_bath <- rast("output_data/campus_bath_epsg2874.tif")
campus_hillshade <- rast("source_data/campus_hillshade.tif")

# we will use the original projection of
#    campus_DEM
# for whatever needs it to overlay:
campus_projection <- crs(campus_DEM)
buildings <- st_transform(buildings, campus_projection)
bikeways <- st_transform(bikeways, campus_projection)
habitat <- st_transform(habitat, campus_projection)
iv_buildings <- st_transform(iv_buildings, campus_projection)
ncos_trails <- st_transform(ncos_trails, campus_projection)

# ###################
# crop rasters to the extent of the main campus:
main_campus_extent <- ext(5998500, 6008500, 1973500, 1982500)

# Crop rasters:
campus_DEM_crop <- crop(campus_DEM, main_campus_extent)
campus_bath_crop <- crop(campus_bath, main_campus_extent)
campus_hillshade_crop <- crop(campus_hillshade, main_campus_extent)

# make dataframes
campus_DEM_df <- as.data.frame(campus_DEM_crop, xy = TRUE) %>%
  rename(elevation = greatercampusDEM_1_1)

campus_bath_df <- as.data.frame(campus_bath_crop, xy = TRUE) %>%
  rename(bathymetry = Bathymetry_2m_OffshoreCoalOilPoint)

campus_hillshade_df <- as.data.frame(campus_hillshade_crop, xy = TRUE)

## test vector overlays
#
# this is our first ggplot, so
# let's make reuse our
# our theme for the first time:
rAtlas_theme <- theme(
  axis.title.x = element_blank(),
  axis.title.y = element_blank(),
  legend.position = "none",
  panel.ontop = TRUE,
  panel.grid.major = element_line(color = "#FFFFFF33"),
  panel.background = element_blank()
)


ggplot() +
  geom_sf(data = habitat) +
  geom_sf(data = buildings) +
  geom_sf(data = iv_buildings) +
  geom_sf(data = bikeways) +
  theme(rAtlas_theme) +
  ggtitle(gg_labelmaker(current_ggplot + 1)) +
  coord_sf()


############################
# now do what's necessary to plot the new
# closest-in #6 rasters together with the 4 vector layers

# let's apply our named theme from map_05


# Render main campus using the same viz as map 1:
final_map6 <- ggplot() +
  geom_raster(data = campus_DEM_df, aes(x = x, y = y, fill = elevation)) +
  geom_raster(data = campus_hillshade_df, aes(x = x, y = y, alpha = hillshade), show.legend = FALSE) +
  geom_raster(data = campus_bath_df, aes(x = x, y = y, fill = bathymetry)) +
  scale_fill_viridis_c(na.value = "NA", guide = guide_legend("bathymetry / elevation (US ft)")) +
  scale_alpha(range = c(0.05, 0.4), guide = "none") +
  geom_sf(data = iv_buildings, color = alpha("light gray", 0.15), fill = NA) +
  geom_sf(data = buildings, color = "pink", fill = alpha("pink", 0.3)) +
  geom_sf(data = habitat, color = alpha("darkorchid1", 0.3), fill = alpha("darkorchid1", 0.1)) +
  geom_sf(data = bikeways, color = "#00abff", linewidth = 0.8) +
  geom_sf(data = ncos_trails, color = "#00abff", linewidth = 0.8) +
  coord_sf(
    xlim = c(main_campus_extent$xmin, main_campus_extent$xmax),
    ylim = c(main_campus_extent$ymin, main_campus_extent$ymax),
    expand = FALSE
  ) +
  labs(
    title = "Map 6: UCSB Main Campus",
    subtitle = "Main campus buildings, environs, bikepaths",
    caption = "rAtlas Map 6"
  ) +
  rAtlas_theme +
  theme(
    plot.title = element_text(size = 18, face = "bold", hjust = 0),
    plot.subtitle = element_text(size = 13, hjust = 0),
    legend.position = "bottom"
  )

final_map6

ggsave("images/map6.1.png", width = 12, height = 4, plot = final_map6, bg = "white")
ggsave("final_output/map_06.png", width = 12, height = 4, plot = final_map6, bg = "white")