The R package ClustGeo implements a Ward-like hierarchical clustering algorithm including spatial/geographical constraints.
Details are available is the following vignette:
https://chavent.github.io/ClustGeo
The package can be installed from GitHub using:
# pak::pak("chavent/ClustGeo")
install.packages("ClustGeo", repos = c('https://chavent.r-universe.dev', 'https://cloud.r-project.org'))
If needed, install pak first:
install.packages("pak")