Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# The date column must then be converted to numeric values
ctd$date <- decimal_date(ctd$date)
# Now we may interpolate the data
ctd_mba <- mba.surf(ctd, no.X = 300, no.Y = 300, extend = T)
dimnames(ctd_mba$xyz.est$z) <- list(ctd_mba$xyz.est$x, ctd_mba$xyz.est$y)
ctd_mba <- melt(ctd_mba$xyz.est$z, varnames = c('date', 'depth'), value.name = 'temp') %>%
filter(depth < 0) %>%
mutate(temp = round(temp, 1))
# Finally we create our gridded result
ggplot(data = ctd_mba, aes(x = date, y = depth)) +
geom_raster(aes(fill = temp)) +
scale_fill_gradientn(colours = rev(ODV_colours)) +
geom_contour(aes(z = temp), binwidth = 2, colour = "black", alpha = 0.2) +
geom_contour(aes(z = temp), breaks = 20, colour = "black") +
### Activate to see which pixels are real and not interpolated
# geom_point(data = ctd, aes(x = date, y = depth),
# colour = 'black', size = 0.2, alpha = 0.4, shape = 8) +
###
labs(y = "depth (m)", x = NULL, fill = "temp. (°C)") +
coord_cartesian(expand = 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment