Created
June 26, 2017 17:04
-
-
Save robwschlegel/c52f7b341b28d461707d3be6f4bd526b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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