1 # Load required packages
5 # Read in the NetCDF file
6 ds <- brick("smoke.nc")
8 # Extract the latitude, longitude, and PM2.5 data
13 # Convert the PM2.5 data to a raster object
14 pm25_raster <- raster(t(pm25))
15 extent(pm25_raster) <- extent(lon[1], lon[length(lon)], lat[length(lat)], lat[1])
17 # Plot the raster object using ggplot2
19 geom_raster(data = as.data.frame(pm25_raster), aes(x = lon, y = lat, fill = value)) +
20 scale_fill_gradient(low = "white", high = "red") +