I need to replicate heatmap that can be found in the link: https://rpubs.com/chrisbrunsdon/gwdplyr
I tried the very approach however I cannot replicate final hexagon colored heatmap.
My main issues is that I am having problem with even creating non colored map, using st_buffer(), st_make_grid()
for some reason it takes a lot of time and then cannot be store because the file is very large.
I provided example that is with location that I need to plot heatmap
on, then values are discrete and shall be use as color in heatmap
library(sf)
library(dplyr)
library(ggplot2)
library(ggspatial)
df <-
data.frame(
x = runif(1000, min = 14.22, max = 14.71),
y = runif(1000, min = 49.94, max = 50.18),
value = sample(c(1:8))
)
hp <-
df%>%
st_as_sf(coords=c("x","y"),crs=27700)
gl_hexes <- st_buffer(hp,1) %>%
st_make_grid(cellsize=c(0.0005, 0.0005),square=FALSE) %>%
st_sf() %>% mutate(hex_ID=sprintf('Hex%04d',row_number()))
I will be thankful for any advice...