Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a hole in Australia #193

Open
paocorrales opened this issue Sep 4, 2024 · 1 comment
Open

There is a hole in Australia #193

paocorrales opened this issue Sep 4, 2024 · 1 comment

Comments

@paocorrales
Copy link
Contributor

paocorrales commented Sep 4, 2024

Adding breaks = seq(-1, 20, 1) fixes the hole.

library(data.table)
library(ggplot2)
library(metR)

obs <- fread("https://raw.githubusercontent.com/paocorrales/t-fall/main/acorn_sat_v2.5.0_daily_tmax/t_fall.csv")

aus <- rnaturalearth::ne_states(country = "Australia", returnclass = "sf")

obs |> 
  ggplot(aes(longitude, latitude)) +
  geom_contour_fill(aes(z = mean_front), kriging = 150, clip = aus) +
  geom_point(aes(fill = mean_front), shape = 21) +
  scale_color_viridis_c(guide = guide_colorbar(barwidth = 0.5,
                                               barheigh = 15), direction = -1) +
  scale_fill_viridis_c(guide = guide_colorbar(barwidth = 0.5,
                                              barheigh = 15), direction = -1) +
  geom_sf(data = aus, inherit.aes = FALSE, fill = NA) +
  coord_sf(ylim = c(-45, -8)) +
  labs(x = NULL, y = NULL, title = "Mean annual occurrence of falls in daily maximum \ntemperature of at least 10 K", 
       fill = NULL) +
  theme_minimal()
@eliocamp
Copy link
Owner

eliocamp commented Sep 4, 2024

The problem is that the kriging algorithm interpolated values outside the observed range (~0, in this case), but the automatic breaks are computed using the data range.

It's not trivial because the breaks are computed in the setup_params step which is run before any step that modifies data in ggplot2. So setup_params would need to krige the data just to throw away the result. I guess I could krige the data at that stage and memoise the result and retrieve it in the compute_group/setup_data step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants