The Journey of Sogdian Tomb Owners from Northern Zhou to Five Dynasties and Ten Kingdoms

By Maria Fang

May 12, 2015

In this RMarkDown you will see the Sogdian tomb owners from four different periods of China, including Northern Zhou, Sui, Tang, and Five Dynasties and Ten Kingdoms. Each map indicates the territory of that period, locations of where each Sogdian individual was either buried, lived, died, or originated from, and lines indicating the journey they took from Central Asia to eventually settle down in China.

library(curl)
library(shapefiles)
library(rgeos)
library(rgdal)
library(maptools)
library(sp)
library(ggplot2)
library(jsonlite)
library(leaflet)
library(knitr)

Loading the datasets from a csv file and a geoJSON file with coordinates of locations.

sogdians.csv <- read.csv("/Users/mariafang/Desktop/NYU/2_AncientData/Week13_Final/sogdiansites.csv", header=TRUE)
locations.geo <- readOGR("https://gist.githubusercontent.com/marsimaria/eef4db6b6eefa57f881e/raw/7a79f7115945c94e49b34aeea959321dc861b3d6/sogdians.geojson", layer="OGRGeoJSON", disambiguateFIDs = T)
## OGR data source with driver: GeoJSON 
## Source: "https://gist.githubusercontent.com/marsimaria/eef4db6b6eefa57f881e/raw/7a79f7115945c94e49b34aeea959321dc861b3d6/sogdians.geojson", layer: "OGRGeoJSON"
## with 16 features and 1 fields
## Feature type: wkbPoint with 2 dimensions

Here are graphs that show the characteristic of our dataset

# Scatter - burial location/ burial period
ggplot(sogdians.csv, aes(period_died, occupant)) + geom_point()

# Bar - Burial Sites
ggplot(sogdians.csv) + geom_bar(aes(burial_site))

# Bar - Death Sites
ggplot(sogdians.csv) + geom_bar(aes(death_site))

# Bar - Lived Sites
ggplot(sogdians.csv) + geom_bar(aes(lived_site))

# Bar - Origin Sites
ggplot(sogdians.csv) + geom_bar(aes(origin))

# Period when buried
ggplot(sogdians.csv) + geom_bar(aes(period_died))

##I created a function for pulling coordinates to create Polylines for the journey for later use

lng= function(n=0, m=0, p=0) locations.geo$coords.x1[cbind(n,m,p)]
lat= function(n=0, m=0, p=0) locations.geo$coords.x2[cbind(n,m,p)]

The Sogdians Tomb Owners in Northern Zhou

## read geojson shp files
nZhougjson <- readOGR("/Users/mariafang/Desktop/NYU/2_AncientData/Week13_Final/georef/norZhou.zip.geojson", layer="OGRGeoJSON", disambiguateFIDs = T)
## OGR data source with driver: GeoJSON 
## Source: "/Users/mariafang/Desktop/NYU/2_AncientData/Week13_Final/georef/norZhou.zip.geojson", layer: "OGRGeoJSON"
## with 1 features and 1 fields
## Feature type: wkbPolygon with 2 dimensions
## Sogidans that died in Northern Zhou
## First subset the Nor zhou deaths
nz.sogs <- subset(sogdians.csv, period_died=="Northern Zhou", select=c(occupant, period_died, death_age, capital, death_site, burial_site, lived_site, origin))
burial.nzsogs <- merge(nz.sogs, locations.geo, by.x='capital', by.y='name')
colnames(burial.nzsogs)[9] <- "longitude"
colnames(burial.nzsogs)[10] <- "latitude"
lived.nzsogs <- merge(nz.sogs, locations.geo, by.x='lived_site', by.y='name')
origin.nzsogs <- merge(nz.sogs, locations.geo, by.x='origin', by.y='name')

## Leaflet Nor Zhou
map <- leaflet() %>% addTiles %>% setView(lng=89.634158, lat=36.320946, zoom=3)
nZhouMap <- map %>% addPolygons(data=nZhougjson, fillColor="black", weight= .5, fillOpacity=.6)
nZhouSogs <- nZhouMap %>% addCircles(data=burial.nzsogs, lng = ~ longitude, lat = ~ latitude, color="red", opacity=1)
nZhouAll <- nZhouSogs %>% addCircles(data=lived.nzsogs, lng = ~coords.x1, lat = ~coords.x2, color="green", opacity=1) %>% addCircles(data=origin.nzsogs, lng = ~coords.x1, lat = ~coords.x2, color="blue", opacity=1)
nZhouFinal <- nZhouAll %>% addPolylines(lng(2,9,13), lat(2,9,13), color="red") %>% addPolylines(lng(2,10,14), lat(2,10,14), color="blue") %>% addPolylines(lng(2,11,15), lat(2,11,15), color="green")
nZhouFinal

The Sogdians Tomb Owners in Sui

## read geojson shp files
suigjson <- readOGR("/Users/mariafang/Desktop/NYU/2_AncientData/Week13_Final/georef/sui.zip.geojson", layer="OGRGeoJSON", disambiguateFIDs = T)
## OGR data source with driver: GeoJSON 
## Source: "/Users/mariafang/Desktop/NYU/2_AncientData/Week13_Final/georef/sui.zip.geojson", layer: "OGRGeoJSON"
## with 2 features and 1 fields
## Feature type: wkbPolygon with 2 dimensions
## Sogidans that died in Sui
## First subset the Sui deaths
sui.sogs <- subset(sogdians.csv, period_died=="Sui", select=c(occupant, period_died, death_age, capital, death_site, burial_site, lived_site, origin))
burial.sui <- merge(sui.sogs, locations.geo, by.x='burial_site', by.y='name')
lived.sui <- merge(nz.sogs, locations.geo, by.x='lived_site', by.y='name')
origin.sui <- merge(nz.sogs, locations.geo, by.x='origin', by.y='name')

## Leaflet Sui
mapSui <- leaflet() %>% addTiles %>% setView(lng=89.634158, lat=36.320946, zoom=3)
suiMap <- mapSui %>% addPolygons(data=suigjson, fillColor="purple", weight= .5, fillOpacity=.6)
suiSogs <- suiMap %>% addCircles(data=burial.sui, lng = ~ coords.x1, lat = ~ coords.x2, color="red", opacity=1)
suiAll <- suiSogs %>% addCircles(data=lived.sui, lng = ~coords.x1, lat = ~coords.x2, color="green", opacity=1) %>% addCircles(data=origin.sui, lng = ~coords.x1, lat = ~coords.x2, color="blue", opacity=1)
suiFinal <- suiAll %>% addPolylines(lng(1,4,14), lat(1,4,14), color="red") %>% addPolylines(lng(1,3), lat(1,3), color="blue")
suiFinal

##The Sogdians Tomb Owners in Tang

## read geojson shp files
tanggjson <- readOGR("/Users/mariafang/Desktop/NYU/2_AncientData/Week13_Final/georef/tang.zip.geojson", layer="OGRGeoJSON", disambiguateFIDs = T)
## OGR data source with driver: GeoJSON 
## Source: "/Users/mariafang/Desktop/NYU/2_AncientData/Week13_Final/georef/tang.zip.geojson", layer: "OGRGeoJSON"
## with 2 features and 1 fields
## Feature type: wkbPolygon with 2 dimensions
## Sogidans that died in Tang
## First subset the Tang deaths
tang.sogs <- subset(sogdians.csv, period_died=="Tang", select=c(occupant, period_died, death_age, capital, death_site, burial_site, lived_site, origin))
burial.tang <- merge(tang.sogs, locations.geo, by.x='burial_site', by.y='name')
lived.tang <- merge(tang.sogs, locations.geo, by.x='lived_site', by.y='name')
origin.tang <- merge(tang.sogs, locations.geo, by.x='origin', by.y='name')

## Leaflet Tang
mapTang <- leaflet() %>% addTiles %>% setView(lng=89.634158, lat=36.320946, zoom=3)
tangMap <- mapTang %>% addPolygons(data=tanggjson, fillColor="pink", weight= .5, fillOpacity=.6)
tangSogs <- tangMap %>% addCircles(data=burial.tang, lng = ~ coords.x1, lat = ~ coords.x2, color="red", opacity=1)
tangAll <- tangSogs %>% addCircles(data=lived.tang, lng = ~coords.x1, lat = ~coords.x2, color="green", opacity=1) %>% addCircles(data=origin.tang, lng = ~coords.x1, lat = ~coords.x2, color="blue", opacity=1)
tangFinal <- tangAll %>% addPolylines(lng(4,14), lat(4,14), color="red") %>% addPolylines(lng(4,14), lat(4,14), color="blue") %>% addPolylines(lng(1,15), lat(1,15), color="blue") %>% addPolylines(lng(1,15), lat(1,15), color="blue") %>% addPolylines(lng(1,15), lat(1,15), color="blue") %>% addPolylines(lng(1,12), lat(1,12), color="blue") %>% addPolylines(lng(1,13), lat(1,13), color="blue") %>% addPolylines(lng(1,13), lat(1,13), color="blue") %>% addPolylines(lng(1,13), lat(1,13), color="blue") %>% addPolylines(lng(2,1,13), lat(2,1,13), color="blue") %>% addPolylines(lng(2,1,15), lat(2,1,15), color="blue") %>% addPolylines(lng(1,15), lat(1,15), color="blue") %>% addPolylines(lng(1,13), lat(1,13), color="blue") %>% addPolylines(lng(1,15), lat(1,15), color="blue") %>% addPolylines(lng(1,13), lat(1,13), color="blue") %>% addPolylines(lng(2,16), lat(2,16), color="blue") %>% addPolylines(lng(6,16), lat(6,16), color="blue") %>% addPolylines(lng(2,16), lat(2,16), color="blue") %>% addPolylines(lng(8,15), lat(8,15), color="blue")
tangFinal

The Sogdians Tomb Owners in Five Dynasties Ten Kingdoms

## read geojson shp files
ftgjson <- readOGR("/Users/mariafang/Desktop/NYU/2_AncientData/Week13_Final/georef/fiveTenshp.geojson", layer="OGRGeoJSON", disambiguateFIDs = T)
## OGR data source with driver: GeoJSON 
## Source: "/Users/mariafang/Desktop/NYU/2_AncientData/Week13_Final/georef/fiveTenshp.geojson", layer: "OGRGeoJSON"
## with 2 features and 1 fields
## Feature type: wkbPolygon with 2 dimensions
## Sogidans that died in fiveten
## First subset the fiveten deaths
ft.sogs <- subset(sogdians.csv, period_died=="FiveTen", select=c(occupant, period_died, death_age, capital, death_site, burial_site, lived_site, origin))
burial.ft <- merge(ft.sogs, locations.geo, by.x='burial_site', by.y='name')
lived.ft <- merge(ft.sogs, locations.geo, by.x='lived_site', by.y='name')
origin.ft <- merge(ft.sogs, locations.geo, by.x='origin', by.y='name')

## Leaflet Five Ten
mapft <- leaflet() %>% addTiles %>% setView(lng=89.634158, lat=36.320946, zoom=3)
ftMap <- mapft %>% addPolygons(data=ftgjson, fillColor="yellow", weight= .5, fillOpacity=.6)
ftSogs <- ftMap %>% addCircles(data=burial.ft, lng = ~ coords.x1, lat = ~ coords.x2, color="red", opacity=1)
ftAll <- ftSogs %>% addCircles(data=origin.ft, lng = ~coords.x1, lat = ~coords.x2, color="blue", opacity=1)
lineft1 <- ftAll %>% addPolylines(lng(1,13), lat(1,13), color="red") %>% addPolylines(lng(1,15), lat(1,15), color="blue")
lineft1