How can I interpolate the water depth over the whole area using kriging?
Thank you
library(tidyverse)
library(sf)
library(tigris)
options(tigris_class = "sf")
point_tib <- tibble(
Points=c(10,20,30),
longitude=c(-84.2,-84.5,-84.7),
latitude=c(34.3,31.3,31.2),
water_depth=c(30,35,10)
)
I tried plotting it in the following code.
point_sf = st_as_sf(point_tib, coords = c("longitude", "latitude"),
crs = 4326, agr = "constant")
states_sf <- states()
point_sf <- st_transform(point_sf, st_crs(states_sf))
states_subset_idx <- st_contains(states_sf, point_sf) %>%
as.data.frame() %>%
pull(row.id)
states_subset <- states_sf %>%
slice(states_subset_idx)
ggplot() +
geom_sf(aes(geometry=geometry), data=states_subset) +
geom_sf(aes(geometry=geometry), data=point_sf)