Created
January 22, 2020 20:31
-
-
Save giocomai/47c9dc21e15264725d107e4def681fd9 to your computer and use it in GitHub Desktop.
Create sync leaflet maps from a Geotiff, see https://www.giorgiocomai.eu/testzone/sibiu1934/
This file contains hidden or 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
--- | |
title: "Sibiu 1934 historic map" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
library("tidyverse") | |
library("leaflet") | |
library("leaflet.opacity") | |
library("tiler") | |
library("leafsync") | |
``` | |
## Create the tiles from a Geotiff | |
```{r} | |
# fs::dir_create("tiles") | |
# tiler::tile(file = "sibiu_map_modified_mercator.tif", | |
# tiles = "tiles", | |
# zoom = "11-18") | |
``` | |
Move them to a server, then check if they work. | |
```{r fig.height=6} | |
leaflet::leaflet() %>% | |
leaflet::addTiles(group = "OpenStreetMap", layerId = "OSM") %>% | |
leaflet::addTiles(urlTemplate = "https://giorgiocomai.eu/testzone/sibiu_tiles_16/{z}/{x}/{-y}.png", | |
group = "Sibiu 1934", | |
layerId = "Sibiu 1934") %>% | |
setView(lng = 24.1519202, lat = 45.7973912, zoom = 14) %>% | |
addLayersControl(baseGroups = c("OpenStreetMap"), | |
overlayGroups = "Sibiu 1934") | |
``` | |
## Combo side by side | |
```{r} | |
base <- leaflet::leaflet() %>% | |
addProviderTiles(providers$OpenStreetMap.Mapnik, group = "Base map") %>% | |
addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>% | |
# leaflet::addTiles(group = "OpenStreetMap", layerId = "OpenStreetMap") %>% | |
setView(lng = 24.1519202, lat = 45.7973912, zoom = 14) %>% | |
addLayersControl(baseGroups = c("Base map", "Satellite")) | |
sibiu1934 <- leaflet::leaflet() %>% | |
leaflet::addTiles(urlTemplate = "https://giorgiocomai.eu/testzone/sibiu_tiles_18/{z}/{x}/{-y}.png", | |
group = "Sibiu 1934", | |
layerId = "Sibiu 1934") %>% | |
setView(lng = 24.1519202, lat = 45.7973912, zoom = 14) | |
combo <- leafsync::sync(sibiu1934, base) | |
``` | |
```{r fig.height=6, fig.width=10} | |
combo | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment