Summary descriptions

col 1

Settlements in the data

1692

The length of all routes

114003 km

The most northern point

54.86714 (Bulġār)

The most southern point

12.79365 (ʿAdan)

The most eastern point

80.03921 (Qannawǧ)

The most western point

-9.6481 (Māssaŧ)

col 2

The Main Map of the Islamic World

Maps of Provinces

col 1

al-Andalus (Islamic Spain)

al-Maġrib (Maghreb, North Africa)

col 2

Mā-warāʾ-l-nahr (Central Asia)

Ḫurāsān (Northeastern Iran)

Data

col 1

Settlements

col 2

Routes

Other stuff

Column

Chart A

Column

Chart B

Chart C

---
title: "Islamic World (11th Century)"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    social: menu
    source_code: embed
---

```{r setup, include=FALSE}

library(flexdashboard)
library(DT)
library(leaflet)

# this is code straight from Lesson 10

# General ones 
library(tidyverse)
library(readr)
library(stringr)
library(ggplot2)
library(ggrepel)
library(ggalt)

# mapping
library(rnaturalearth)
library(rnaturalearthdata)
library(grid) # grid library cuts out the plot from the graph


RDSfolder="./map_objects/"

rivers_df <- readRDS(paste0(RDSfolder,"rivers_df.rds"))
aral_sea_df <- readRDS(paste0(RDSfolder,"aral_sea_df.rds"))
routes_df <- readRDS(paste0(RDSfolder,"routes_df.rds"))

world <- ne_countries(scale="medium", returnclass="sf")

colWater= "lightsteelblue2"
colLand = "white"
colRout = "grey"

#xlimVal=c(-12,80); ylimVal=c(10,50)
IslamicWorldBaseBare <- ggplot(data=world) +
  geom_sf(fill=colLand, color=colLand) +
  # rivers, aral sea, and routes
  geom_path(data=routes_df, aes(x=long, y=lat, group=id), color=colRout, size=.2) +
  geom_path(data=rivers_df, aes(x=long, y=lat, group=group), color=colWater, alpha=1, size=.3) +
  geom_polygon(data=aral_sea_df, aes(x=long, y=lat, group=group), color=colWater, fill=colWater, size=.2) +
  # map limits and theme
  #coord_sf(xlim=xlimVal, ylim=ylimVal, expand=FALSE) +
  theme(panel.grid.major=element_line(color=colWater, linetype="dotted", size=0.5),
        panel.background=element_rect(fill=colWater),legend.position="none", panel.border=element_blank())


# EDGES

edges <- read_delim("./althurayya/routes.csv", 
    "\t", escape_double = FALSE, trim_ws = TRUE)

edges <- edges %>%
  mutate(weight = meter) %>%
  select(sToponym, eToponym, weight, meter, terrain, safety)

# NODES

nodes <- read_delim("./althurayya/settlements.csv", 
    "\t", escape_double = FALSE, trim_ws = TRUE)

nodes <- nodes %>%
  separate(col=coordinates, into=c("l", "lon", "lat", "r"), sep="([\\[, \\]]+)") %>%
  select(settlement_id, names_eng_translit, region_URI, top_type, lon, lat) %>%
  mutate(lon = as.numeric(lon), lat = as.numeric(lat))

# remove nodes which are not in the network
nwNodes <- unique(c(edges$sToponym, edges$eToponym))

nodes <- nodes %>%
  filter(settlement_id %in% nwNodes)

# METROPOLES

nodesTop <- nodes %>%
  filter(top_type == "metropoles")

annotData <- nodesTop

metropoles <- IslamicWorldBaseBare + 
  geom_point(data = nodes, aes(x=lon, y=lat, col=region_URI), alpha=1, size=0.25) +
  geom_point(data = annotData, aes(x=lon, y=lat), col="red", size=1) +
  geom_label_repel(data = annotData, aes(label = names_eng_translit, x=lon, y=lat)) + 
  coord_sf(xlim=c(min(nodes$lon)-1, max(nodes$lon)+1),
           ylim=c(min(nodes$lat)-1, max(nodes$lat)+1),
                 expand=FALSE) +
  theme(legend.position="none")

# # LEAFLET MAP - from lesson 11
# 
# iwSettlements <- read_delim("./althurayya/settlements.csv",
#                             "\t", escape_double = FALSE, trim_ws = TRUE) %>%
#   separate(col=coordinates, into=c("l", "lon", "lat", "r"), sep="([\\[, \\]]+)") %>%
#   select(settlement_id, names_eng_translit, region_URI, top_type, lon, lat) %>%
#   mutate(lon = as.numeric(lon), lat = as.numeric(lat))
# 
# iwRoutes <- read_delim("./althurayya/routes.csv", 
#     "\t", escape_double = FALSE, trim_ws = TRUE)
# 
# # additional data for regions -- simply loading
# iwRegions <- read_delim("./althurayya/regions.csv",
#                             "\t", escape_double = FALSE, trim_ws = TRUE)
# 
# # additional data for sizing
# types <- tibble(top_type = unique(iwSettlements$top_type),
#                 size = c(5, 3, 0, 2, 0, 1, 0, 4, 0, 0))
# 
# # now let's add everything with left_join, and then format a pop-up message
# iwSettlementsMOD <- iwSettlements %>%
#   left_join(iwRegions, by = c("region_URI")) %>%
#   left_join(types, by = c("top_type")) %>%
#   mutate(popup = paste0("", names_eng_translit, " is one of ", top_type,
#                         ". It is located in the province of ", region_name, " (", 
#                         lon, ", ", lat, ").")) %>%
#   filter(top_type %in% c("metropoles", "capitals", "towns", "villages", "waystations"))
```

# Sidebar {.sidebar}

This is a new working version of the al-Ṯurayyā project which currently includes the gazetteer (al-Ṯurayyā Gazetteer, or al-Thurayyā Gazetteer), and the geospatial model of the early Islamic world. Both parts of the project are still under development.

The gazetteer currently includes over 2,000 toponyms and almost as many route sections georeferenced from Georgette Cornu’s Atlas du monde arabo-islamique à l'époque classique: IXe-Xe siècles (Leiden: Brill, 1983).

The previous version of the gazetteer can be found here. You can browse this version by clicking on any toponym marker. The popup will show the toponym both in Arabic script and transliterated (On transliteration scheme, see below). The popup also offers a selection of possible sources on a toponym in question. You can check Arabic Sources: currently, al-Samʿānī’s Kitāb al-ansāb and Yāqūt’s Muʿjam al-buldān. The Gazetteer shows only exact matches, which means that in some cases there will not be any entry at all, while in other cases there may be more than one and they may refer to other places with the same name. You can also check if there is information on a toponym in question in Brill’s Encyclopaedia of Islam, Pleiades, and Wikipedia.


Note on the transliteration scheme: The website uses a somewhat unconventional transliteration system, which was developed to facilitate computational analysis. Unlike more traditional transliteration schemes the current one uses one-to-one letter representation, with every Arabic letter transcribed distinctively, which allows for an automatic conversion between transliteration and the Arabic script. The overall scheme should be easily recognizable to Arabists (new letters are as follows: ŧ for tāʾ marbuṭaŧ; ã for dagger alif; and á for alif maqṣūraŧ).


# Summary descriptions

## col 1 {data-width=300}

### Settlements in the data

```{r}
settlements <- nrow(nodes)
valueBox(settlements, icon = "fa-map")
```

### The length of all routes

```{r}
settlements <- as.integer(sum(edges$meter)/1000)
valueBox(paste0(settlements, " km"), icon = "fa-road")
```

### The most northern point

```{r}
place <- nodes %>% arrange(desc(lat)) %>% head(1)

valueBox(paste0(place$lat, " (", place$names_eng_translit, ")"), icon = "fa-arrow-up")
```

### The most southern point

```{r}
place <- nodes %>% arrange(desc(lat)) %>% tail(1)

valueBox(paste0(place$lat, " (", place$names_eng_translit, ")"), icon = "fa-arrow-down")
```

### The most eastern point

```{r}
place <- nodes %>% arrange(desc(lon)) %>% head(1)

valueBox(paste0(place$lon, " (", place$names_eng_translit, ")"), icon = "fa-arrow-right")
```

### The most western point

```{r}
place <- nodes %>% arrange(desc(lon)) %>% tail(1)

valueBox(paste0(place$lon, " (", place$names_eng_translit, ")"), icon = "fa-arrow-left")
```

## col 2

### The Main Map of the Islamic World

```{r, fig.width=10, fig.height=6}

metropoles

# leaflet(iwSettlementsMOD) %>%
#   # Base groups
#   addProviderTiles(providers$Esri.WorldPhysical, group = "World Physical (ESRI)") %>%
#   addProviderTiles(providers$Esri.WorldTerrain, group = "World Terrain (ESRI)") %>%
#   addProviderTiles(providers$Esri.WorldImagery, group = "World Imagery (ESRI)") %>%
#   addProviderTiles(providers$Esri.WorldShadedRelief, group = "World ShadowRelief (ESRI)") %>%
#   setView(32, 32, zoom = 5) %>%
#   # Overlay groups
#   addCircles(~lon, ~lat, popup=~popup, weight = ~size*2, radius=~size*10, 
#                  color=~region_color, stroke = TRUE, fillOpacity = 1, group = "All regions")  %>%
#   addLabelOnlyMarkers(~lon, ~lat, label=~names_eng_translit, labelOptions = labelOptions(noHide = F)) %>%
#   # Layers control
#   addLayersControl(
#     baseGroups = c("World Physical (ESRI)", "World Terrain (ESRI)", "World Imagery (ESRI)", "World ShadowRelief (ESRI)"),
#     overlayGroups = c("All regions"),
#     options = layersControlOptions(collapsed = FALSE)
#   )

```

# Maps of Provinces

## col 1

### al-Andalus (Islamic Spain)

```{r fig.height=15, fig.width=20}
nodesProv <- nodes %>%
  filter(region_URI == "Andalus_RE") %>%
  filter(top_type %in% c("metropoles", "capitals", "towns", "villages"))

annotData <- nodesProv

province <- IslamicWorldBaseBare + 
  geom_point(data = nodes, aes(x=lon, y=lat, col=region_URI), alpha=1, size=0.25) +
  geom_point(data = annotData, aes(x=lon, y=lat), col="red", size=1) +
  geom_label_repel(data = annotData, aes(label = names_eng_translit, x=lon, y=lat)) + 
  coord_sf(xlim=c(min(nodesProv$lon)-1, max(nodesProv$lon)+1),
           ylim=c(min(nodesProv$lat)-1, max(nodesProv$lat)+1),
                 expand=FALSE) +
  theme(legend.position="none")

gt <- ggplot_gtable(ggplot_build(province))
ge <- subset(gt$layout, name == "panel")

grid.draw(gt[ge$t:ge$b, ge$l:ge$r])
```

### al-Maġrib (Maghreb, North Africa)

```{r fig.height=15, fig.width=20}
nodesProv <- nodes %>%
  filter(region_URI == "Maghrib_RE") %>%
  filter(top_type %in% c("metropoles", "capitals", "towns", "villages"))

annotData <- nodesProv

province <- IslamicWorldBaseBare + 
  geom_point(data = nodes, aes(x=lon, y=lat, col=region_URI), alpha=1, size=0.25) +
  geom_point(data = annotData, aes(x=lon, y=lat), col="red", size=1) +
  geom_label_repel(data = annotData, aes(label = names_eng_translit, x=lon, y=lat)) + 
  coord_sf(xlim=c(min(nodesProv$lon)-1, max(nodesProv$lon)+1),
           ylim=c(min(nodesProv$lat)-1, max(nodesProv$lat)+1),
                 expand=FALSE) +
  theme(legend.position="none")

gt <- ggplot_gtable(ggplot_build(province))
ge <- subset(gt$layout, name == "panel")

grid.draw(gt[ge$t:ge$b, ge$l:ge$r])
```

## col 2

### Mā-warāʾ-l-nahr (Central Asia)

```{r fig.height=15, fig.width=20}
nodesProv <- nodes %>%
  filter(region_URI == "Mawarannahr_RE") %>%
  filter(top_type %in% c("metropoles", "capitals", "towns", "villages"))

annotData <- nodesProv

province <- IslamicWorldBaseBare + 
  geom_point(data = nodes, aes(x=lon, y=lat, col=region_URI), alpha=1, size=0.25) +
  geom_point(data = annotData, aes(x=lon, y=lat), col="red", size=1) +
  geom_label_repel(data = annotData, aes(label = names_eng_translit, x=lon, y=lat)) + 
  coord_sf(xlim=c(min(nodesProv$lon)-1, max(nodesProv$lon)+1),
           ylim=c(min(nodesProv$lat)-1, max(nodesProv$lat)+1),
                 expand=FALSE) +
  theme(legend.position="none")

gt <- ggplot_gtable(ggplot_build(province))
ge <- subset(gt$layout, name == "panel")

grid.draw(gt[ge$t:ge$b, ge$l:ge$r])
```

### Ḫurāsān (Northeastern Iran)

```{r fig.height=15, fig.width=20}
nodesProv <- nodes %>%
  filter(region_URI == "Khurasan_RE") %>%
  filter(top_type %in% c("metropoles", "capitals", "towns", "villages"))

annotData <- nodesProv

province <- IslamicWorldBaseBare + 
  geom_point(data = nodes, aes(x=lon, y=lat, col=region_URI), alpha=1, size=0.25) +
  geom_point(data = annotData, aes(x=lon, y=lat), col="red", size=1) +
  geom_label_repel(data = annotData, aes(label = names_eng_translit, x=lon, y=lat)) + 
  coord_sf(xlim=c(min(nodesProv$lon)-1, max(nodesProv$lon)+1),
           ylim=c(min(nodesProv$lat)-1, max(nodesProv$lat)+1),
                 expand=FALSE) +
  theme(legend.position="none")

gt <- ggplot_gtable(ggplot_build(province))
ge <- subset(gt$layout, name == "panel")

grid.draw(gt[ge$t:ge$b, ge$l:ge$r])
```


# Data

## col 1

### Settlements

```{r}
datatable(nodes, options = list(pageLength = 50))
```

## col 2

### Routes

```{r}
datatable(edges, options = list(pageLength = 50))
```

# Other stuff

## Column {data-width=650}

### Chart A

```{r}

```

## Column {data-width=350}

### Chart B

```{r}

```

### Chart C

```{r}

```