[Note: On March 11th, the ISAW seminar “Mapping and Data Vizualization for the Ancient World” put together this rmarkdown document. Edited only by the addition of this note. See source here . The interactive maps and charts seem to work best in OS X Safari… It’s just an in-class exercise but we had fun doing it. -Sebastian]

Require packages

require(curl) #read.csv fucntion
require(jsonlite)  #fromJSON function
require(plyr) #join function
require(DT) #Runif function (generate random numbers)
require(rgdal) #condinates and #readOGRfunction
require(quantmod)
require(lubridate)
require(zoo)
require(metricsgraphics)
require(RColorBrewer)
require(leaflet)
require(maps)
require(dygraphs)

Load data

ramphs <-read.csv(curl("https://gist.githubusercontent.com/sfsheath/5c5987269e8aad412416/raw/a12dda2b8a681f1ab01421f68ac237ab591ff0f9/roman-amphitheaters.csv"))
periods <- fromJSON("https://gist.githubusercontent.com/sfsheath/cc082cc6db3ac8343e3a/raw/6e938ed37b9083f393a67bec10b46ba7fc693661/amphitheater-chronogrps.json")

Joining dataframes

Identify rows in the colum called chronogrp in the dataframes “ramphs” and “periods” wihch contain the same information and colapse them in to a new dataframe called ramphs.joined

join(ramphs, periods, by= "chronogrp") -> ramphs.joined
coordinates(ramphs.joined) <- ~longitude + latitude

#Verify that the data loaded correctly by checking its class and looking at the first 5 rows
class(ramphs.joined)
## [1] "SpatialPointsDataFrame"
## attr(,"package")
## [1] "sp"
datatable(data.frame(ramphs.joined[1:5,]))

###Create noise #### Generate noise based on the difference between start date and end date

ramphs.noise <- ramphs.joined
for(i in 1:length(periods$chronogrp)){
  start.noise.periods <- ramphs.noise$start_date[ramphs.noise$chronogrp== periods$chronogrp[i]]
  end.noise.periods <- ramphs.noise$end_date[ramphs.noise$chronogrp== periods$chronogrp[i]]
  tmp.length <- length(start.noise.periods)
  tmp.min  <- min(start.noise.periods)
  tmp.max  <- max(end.noise.periods)
  noise.periods <- runif(tmp.length,min=tmp.min,max=tmp.max)
  ramphs.joined$start_date[ramphs.joined$chronogrp== periods$chronogrp[i]] <- round(noise.periods)
}

Make a Spatial dataframe

Making a spatial dataframe of the ramphs dataset and make a plot of it.

load(curl("https://gist.githubusercontent.com/sfsheath/51b4565d843d9a057a43/raw/awmc.RData")) 
#readOGR("https://gist.githubusercontent.com/sfsheath/7726c6f5fff9aa45ee15/raw/rome200.#geojson", layer = "OGRGeoJSON", disambiguateFIDs = T) -> rome200.sp
plot(awmc.roman.empire.200.sp)
plot(ramphs.joined, add = T)

#```


### Making cumulative time series chart
####This section converts the dates from integers to a date class.
(min(ramphs.joined$start_date)*-1)+5 -> n
#Calculates the minimum start date, converts it to a positive, and adds 5 years to ensure all values are above 0
ramphs.joined$start_date + n -> ndate
d <- paste((ndate),"01", "01")
#Adds a month and date to the year because R will not convert years alone
dates <- as.Date(d, "%Y%m%d")
#Changes the class from integer to date
dates-period(n, units="years") -> rs.dates
#Subtracts the period, "n", from the date class to return the original year values using package "lubridate"
class(rs.dates)
## [1] "Date"
#Verifies the class of date column "rs.dates"

Make cumulatively summed zoo object for capacity

zoo.cap <- zoo((ramphs$capacity), rs.dates)

aggregate(zoo.cap, identity, sum, na.rm = T) -> zoo.cap.ag

cumsum(zoo.cap.ag) -> zoo.cap.cumsummed

plot(zoo.cap.cumsummed)

# zoo.ext.cumsummed

Make zoo objects for ExtMajor

Cumulatively summed zoo object for capacity, by Hugo

zoo.extmajor <- zoo((ramphs$extmajor), rs.dates)
aggregate(zoo.extmajor, identity, sum, na.rm = T) -> zoo.extmajor.ag
cumsum(zoo.extmajor.ag) -> zoo.extmajor.cumsummed
plot(zoo.extmajor.cumsummed)

Make a zoo object showing the minor extension (Kate)

zoo.extminor <- zoo((ramphs$extminor), rs.dates)

aggregate(zoo.extminor, identity, sum, na.rm = T) -> zoo.extminor.ag

cumsum(zoo.extminor.ag) -> zoo.extminor.cumsumed

plot(zoo.extminor.cumsumed)

Make leaflet of the roman empire outline and locations of the amphitheaters (Maria F.)

m <- leaflet(ramphs) %>% addTiles()
m %>% addPolylines(data = awmc.roman.empire.200.sp, color = "red", weight = 4) %>% addCircles(lat = ~ latitude, lng = ~ longitude)

Make a zoo object show the cumulative population in Amphitheaters over the years

Composed by Dalit Shalom

#make a copy of the original dataset
ramphs.joined -> ds.ramphs.joined.population
#asign 0 to all the NA in "population"
ds.ramphs.joined.population$population[is.na(ds.ramphs.joined.population$population)] <- 0
#plot graph of relationship between years and cumulative capacity 
plot(cumsum(zoo((ds.ramphs.joined.population$population), rs.dates)))

#Build Dygraphs
dygraph(cumsum(zoo((ds.ramphs.joined.population$population), rs.dates)))%>%
dyRangeSelector(dateWindow = c("0-01-01", "300-01-01"))

Compare cumulative populations by country(Will)

#make copy
wf.ramphs.cop <- join(ramphs, periods, by= "chronogrp")
#keep years positive
wf.ramphs.cop$start_date<-sprintf("%s",wf.ramphs.cop$start_date+100);
#format
wf.ramphs.cop$start_date<-paste(wf.ramphs.cop$start_date,"-01-01",sep = "")
#create zoo object
ramphs.zdate<-as.Date(wf.ramphs.cop$start_date)
#Correct for 100 year addition to dates by adding 36524.25 days
ramphs.zdate<-ramphs.zdate-36524.25
#remove null populations
wf.ramphs.cop$population[is.na(wf.ramphs.cop$population)]<-0
#plot each country individually
plot(cumsum(zoo((wf.ramphs.cop$population[wf.ramphs.cop$modcountry=="Italy"]), ramphs.zdate)), col="red", ylab="Population", yaxt="n", xlab="Year")
par(new = TRUE)
plot(cumsum(zoo((wf.ramphs.cop$population[wf.ramphs.cop$modcountry=="Syria"]), ramphs.zdate)),col="blue", ylab="Population", yaxt="n", xlab="Year")
par(new = TRUE)
plot(cumsum(zoo((wf.ramphs.cop$population[wf.ramphs.cop$modcountry=="France"]), ramphs.zdate)),col="green", ylab="Population", yaxt="n", xlab="Year")
par(new = TRUE)
plot(cumsum(zoo((wf.ramphs.cop$population[wf.ramphs.cop$modcountry=="Austria"]), ramphs.zdate)),col="black", ylab="Population", yaxt="n", xlab="Year")

##Effort and Amphitheatres (Allison) The goal of this section is to determine when/whether there were periods of time during which the Romans were investing more effort into constructing amphitheatres. This will be done primarily through dividing up the data on distance to the nearest quarry using a similar process to above. The plot will be created slightly differently.

Creation of Quartiles

Using a similar process as above, a column will be created dividing the data on nearest quarry into quartiles.

join(ramphs, periods, by= "chronogrp") -> ramphs.joined.aw
stone.aw <- ramphs.joined.aw
stone.aw <- within(stone.aw, quartile <- as.integer(cut(quarries.nearest, quantile(quarries.nearest, probs=0:4/4), include.lowest=TRUE)))

Plotting the “effort” data

In addition to the quartile data for nearest quarry, I used the existing “elevation quartile” column in order to create points of different sizes. This assumes that higher elevation locations required greater effort to construct the amphitheatre.

mjs_plot(stone.aw, x=start_date, y=quarries.nearest) %>% mjs_point(color_accessor=quartile, color_range=brewer.pal(n=8, name="Dark2")[c(1, 2, 4, 6, 8)], size_accessor=elevation.quartile) %>%mjs_labs(x="Earliest Possible Construction Date", y="Distance to the Nearest Quarry")

An Interactive Map of the “Effort” Data

Repeating the process above from the other leaflet maps, I created a fourth leaflet map to display the distance to the quarry by color-coded quartile. As before, colors were selected in the order of the rainbow, with red as the lowest quartile and purple as the highest quartile.

coordinates(stone.aw) <- ~longitude + latitude
proj4string(stone.aw) <- CRS('+proj=longlat +datum=WGS84')
leaflet() %>% addTiles() %>% addCircles(data=stone.aw[stone.aw$quartile==1,], color="red")  %>% addCircles(data=stone.aw[stone.aw$quartile==2,], color="orange")  %>% addCircles(data=stone.aw[stone.aw$quartile==3,], color="blue")  %>% addCircles(data=stone.aw[stone.aw$quartile==4,], color="purple")  

Observations

It is interesting to note that the interactive scatterplot shows a significant amount of “high effort” amphitheatre construction during the first century AD. I had initially created the map thinking that the greater effort would come with greater expansion of Roman territory. The map also shows that the highest quartile of distance to quarry is both concentrated in eastern Italy and spread throughout the far ends of the Roman provinces. I did not expect to see this clustering of high distance to quarry within Italy.