├── DESCRIPTION ├── NAMESPACE ├── R ├── data.R └── weighted.deciles.R ├── README.md ├── cawd.Rproj ├── data ├── awmc.persian.extent.sp.rda ├── awmc.roman.empire.117.sp.rda ├── awmc.roman.empire.200.sp.rda ├── awmc.roman.senatorial.sp.rda ├── awmc.roman.territory.60bc.sp.rda ├── awmc.senatorial.sp.rda ├── darmc.rats.1to1500.sp.rda ├── darmc.roman.roads.major.sp.rda ├── darmc.shipwrecks.rda ├── darmc.shipwrecks.sp.rda ├── nomisma.greek.mints.rda ├── nomisma.greek.mints.sp.rda ├── nomisma.roman.mints.rda ├── nomisma.roman.mints.sp.rda ├── nomisma.roman.provincial.mints.rda ├── nomisma.roman.provincial.mints.sp.rda ├── orbis.edges.rda ├── orbis.nodes.rda ├── ramphs.chrono.grps.rda ├── ramphs.rda └── ramphs.sp.rda ├── inst ├── rmarkdown │ ├── amphitheater-heatmaps.Rmd │ ├── amphitheater-heatmaps.html │ ├── darmc-rat-maps.Rmd │ ├── darmc-rat-maps.html │ ├── margin-histograms.Rmd │ ├── margin-histograms.html │ ├── nearest-amphitheaters.Rmd │ ├── nearest-amphitheaters.html │ ├── orbis-rome-near.Rmd │ ├── orbis-rome-near.html │ ├── torome.Rmd │ └── torome.html └── scripts │ ├── collect.awmc.R │ ├── collect.darmc.rats.1to1500.R │ ├── collect.darmc.shipwrecks.R │ ├── collect.nomisma.R │ ├── collect.orbis.R │ └── collect.ramphs.R └── man ├── awmc.persian.extent.sp.Rd ├── awmc.roman.empire.117.sp.Rd ├── awmc.roman.empire.200.sp.Rd ├── awmc.roman.senatorial.sp.Rd ├── awmc.roman.territory.60bc.sp.Rd ├── awmc.senatorial.sp.Rd ├── darmc.rats.1to1500.sp.Rd ├── darmc.shipwrecks.Rd ├── darmc.shipwrecks.sp.Rd ├── nomisma.greek.mints.Rd ├── nomisma.greek.mints.sp.Rd ├── nomisma.roman.mints.Rd ├── nomisma.roman.mints.sp.Rd ├── nomisma.roman.provincial.mints.Rd ├── nomisma.roman.provincial.mints.sp.Rd ├── orbis.edges.Rd ├── orbis.nodes.Rd ├── ramphs.Rd ├── ramphs.chrono.grps.Rd └── weighted.deciles.Rd /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: cawd 2 | Title: Collected Ancient World Data 3 | Version: 0.0.0.1000 4 | Authors@R: person("Sebsatian", "Heath", , "sebastian.heath@nyu.edu", role = c("aut", "cre")) 5 | Description: Collected open-licensed data for the Ancient World. Please note that the CC0 license applies to any original work inherent only in the collection of the data. Each source used is licensed by its authors. Users of this package should make sure their use of data in this package complies with the data's original license. 6 | Depends: R (>= 3.1.2) 7 | License: CC0 8 | LazyData: true 9 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | exportPattern("^[^\\.]") 2 | -------------------------------------------------------------------------------- /R/data.R: -------------------------------------------------------------------------------- 1 | #' AWMC Map of Persian Empire. 2 | #' 3 | #' Available from the Ancient World Mapping Center under an CC-BY-NC License 4 | #' 5 | #' @format SP object 6 | #' @source \url{http://awmc.unc.edu} 7 | "awmc.persian.extent.sp" 8 | #' AWMC Map of Roman Senatorial Provinces. 9 | #' 10 | #' Available from the Ancient World Mapping Center under an CC-BY-NC License 11 | #' 12 | #' @format SP object 13 | #' @source \url{http://awmc.unc.edu} 14 | "awmc.roman.senatorial.sp" 15 | #' AWMC Map of Roman Territory in 60 BC. 16 | #' 17 | #' Available from the Ancient World Mapping Center under an CC-BY-NC License 18 | #' 19 | #' @format SP object 20 | #' @source \url{http://awmc.unc.edu} 21 | "awmc.roman.territory.60bc.sp" 22 | #' AWMC Map of Roman Empire in 117 AD. 23 | #' 24 | #' Available from the Ancient World Mapping Center under an CC-BY-NC License 25 | #' 26 | #' @format SP object 27 | #' @source \url{http://awmc.unc.edu} 28 | "awmc.roman.empire.117.sp" 29 | #' AWMC Map of Roman Empire in 200 AD. 30 | #' 31 | #' Available from the Ancient World Mapping Center under an CC-BY-NC License 32 | #' 33 | #' @format SP object 34 | #' @source \url{http://awmc.unc.edu} 35 | "awmc.roman.empire.200.sp" 36 | #' AWMC Map of Senatorial Provinces of the Roman Empire 37 | #' 38 | #' Available from the Ancient World Mapping Center under an CC-BY-NC License 39 | #' 40 | #' @format SP object 41 | #' @source \url{http://awmc.unc.edu} 42 | "awmc.senatorial.sp" 43 | #' DARMC Rat Remains 44 | #' 45 | #' Digital Atlas of Roman and Medieval Civilization data on archaeologically record rat remains. Available under a CC-BY-NC-SA license. See source for details. 46 | #' 47 | #' The file has a few 0,0 lat/long pairs so it is probably best to remove those before plotting. 48 | #' 49 | #' @format SP object 50 | #' @source \url{http://darmc.harvard.edu/icb/icb.do?keyword=k40248&pageid=icb.page601659} 51 | "darmc.rats.1to1500.sp" 52 | #' DARMC Shipwrekcs 53 | #' 54 | #' Digital Atlas of Roman and Medieval Civilization data on shipwrecks. Available under a CC-BY-NC-SA license. See source for details. 55 | #' 56 | #' @format data.frame 57 | #' @source \url{http://darmc.harvard.edu/icb/icb.do?keyword=k40248&pageid=icb.page601659} 58 | "darmc.shipwrecks" 59 | #' DARMC Shipwrekcs (SP) 60 | #' 61 | #' Digital Atlas of Roman and Medieval Civilization data on shipwrecks as an sp object. Available under a CC-BY-NC-SA license. See source for details. 62 | #' 63 | #' @format SP Object 64 | #' @source \url{http://darmc.harvard.edu/icb/icb.do?keyword=k40248&pageid=icb.page601659} 65 | "darmc.shipwrecks.sp" 66 | #' Nomisma.org: Greek Mints 67 | #' 68 | #' Data available under a CC-By license. All mints said by Nomisma to be "part of" Greek numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient cultural affinity. 69 | #' 70 | #' @format A data frame (needs info on columns) 71 | #' @source \url{http://nomisma.org/} 72 | "nomisma.greek.mints" 73 | #' Nomisma.org: Greek Mints (sp) 74 | #' 75 | #' Data available under a CC-By license. All mints said by Nomisma to be "part of" Greek numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient cultural affinity. 76 | #' 77 | #' @format SP Object (needs info on columns) 78 | #' @source \url{http://nomisma.org/} 79 | "nomisma.greek.mints.sp" 80 | #' Nomisma.org: Roman Mints 81 | #' 82 | #' Data available under a CC-By license. All mints said by Nomisma to be "part of" Roman numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient poltical circumstances. 83 | #' 84 | #' @format A data frame (needs info on columns) 85 | #' @source \url{http://nomisma.org/} 86 | "nomisma.roman.mints" 87 | #' Nomisma.org: Roman Mints (sp) 88 | #' 89 | #' Data available under a CC-By license. All mints said by Nomisma to be "part of" Roman numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient political circumstances. 90 | #' 91 | #' @format SP Object (needs info on columns) 92 | #' @source \url{http://nomisma.org/} 93 | "nomisma.roman.mints.sp" 94 | #' Nomisma.org: Roman Provincial Mints (Incomplete) 95 | #' 96 | #' Data available under a CC-By license. All mints said by Nomisma to be "part of" Roman numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient politcal circumstances. 97 | #' 98 | #' @format A data frame (needs info on columns) 99 | #' @source \url{http://nomisma.org/} 100 | "nomisma.roman.provincial.mints" 101 | #' Nomisma.org: Roman Provincial Mints (sp) (Incomplete) 102 | #' 103 | #' Data available under a CC-By license. All mints said by Nomisma to be "part of" Roman numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient political circumstances. 104 | #' 105 | #' @format SP Object (needs info on columns) 106 | #' @source \url{http://nomisma.org/} 107 | "nomisma.roman.provincial.mints.sp" 108 | #' Stanford Orbis Model of Roman Connectivity: Edges 109 | #' 110 | #' Data available under a CC-By license. 111 | #' 112 | #' @format A data frame (needs info on columns) 113 | #' @source \url{http://purl.stanford.edu/mn425tz9757} 114 | "orbis.edges" 115 | #' Stanford Orbis Model of Roman Connectivity: Nodes 116 | #' 117 | #' The API is public but does not give an explicit license. 118 | #' 119 | #' @format A data frame (needs info on columns) 120 | #' @source \url{http://orbis.stanford.edu/api} 121 | "orbis.nodes" 122 | #' Roman Amphitheaters. 123 | #' 124 | #' Data for Roman amphitheaters. 125 | #' 126 | #' @format A data frame (needs info on columns) 127 | #' @source \url{http://github.com/sfsheath/roman-amphitheaters} 128 | "ramphs" 129 | #' Roman Amphitheaters: Chronological Groups. 130 | #' 131 | #' Provides start dates and end dates for the chronological groups in the chrono.grp column of the ramphs object. merge() can be used to combine the two objects. 132 | #' 133 | #' @format A data frame (needs info on columns) 134 | #' @source \url{http://github.com/sfsheath/roman-amphitheaters} 135 | "ramphs.chrono.grps" 136 | -------------------------------------------------------------------------------- /R/weighted.deciles.R: -------------------------------------------------------------------------------- 1 | #' Weighted Deciles 2 | #' 3 | #' Weighted Cumulative Cumulative Sum of 4 | #' 5 | weighted.deciles <- function(Qv, 6 | Wv, 7 | decile.title = "", 8 | decile.xlab = "", 9 | decile.ylab = "", 10 | scale.name = "") { 11 | 12 | # clear the plot window 13 | 14 | require(ggplot2) 15 | require(Hmisc) 16 | 17 | 18 | Qsv <- cut(Qv, breaks = wtd.quantile(Qv, weights = Wv, probs = 0:10/10), include.lowest=TRUE, labels=FALSE) 19 | 20 | 21 | 22 | # calculate max() and min() values for quartiles. These will be labels on chart 23 | 24 | one.label = paste(round(min(Qv[Qsv == 1]), digit = 2), 25 | "-", 26 | round(max(Qv[Qsv == 1]), digit =2), 27 | " (",round(sum(Wv[Qsv <= 1])),")") 28 | 29 | two.label = paste(round(min(Qv[Qsv == 2]), digit = 2), 30 | "-", 31 | round(max(Qv[Qsv == 2]), digit =2), 32 | " (",round(sum(Wv[Qsv <= 2])),")") 33 | 34 | three.label = paste(round(min(Qv[Qsv == 3]), digit = 2), 35 | "-", 36 | round(max(Qv[Qsv == 3]), digit =2), 37 | " (",round(sum(Wv[Qsv <= 3])),")") 38 | 39 | four.label = paste(round(min(Qv[Qsv == 4]), digit = 2), 40 | "-", 41 | round(max(Qv[Qsv == 4]), digit =2), 42 | " (",round(sum(Wv[Qsv <= 4])),")") 43 | 44 | five.label = paste(round(min(Qv[Qsv == 5]), digit = 2), 45 | "-", 46 | round(max(Qv[Qsv == 5]), digit =2), 47 | " (",round(sum(Wv[Qsv <= 5])),")") 48 | 49 | six.label = paste(round(min(Qv[Qsv == 6]), digit = 2), 50 | "-", 51 | round(max(Qv[Qsv == 6]), digit =2), 52 | " (",round(sum(Wv[Qsv <= 6])),")") 53 | 54 | seven.label = paste(round(min(Qv[Qsv == 7]), digit = 2), 55 | "-", 56 | round(max(Qv[Qsv == 7]), digit =2), 57 | " (",round(sum(Wv[Qsv <= 7])),")") 58 | 59 | eight.label = paste(round(min(Qv[Qsv == 8]), digit = 2), 60 | "-", 61 | round(max(Qv[Qsv == 8]), digit =2), 62 | " (",round(sum(Wv[Qsv <= 8])),")") 63 | 64 | nine.label = paste(round(min(Qv[Qsv == 9]), digit = 2), 65 | "-", 66 | round(max(Qv[Qsv == 9]), digit =2), 67 | " (",round(sum(Wv[Qsv <= 9])),")") 68 | 69 | ten.label = paste(round(min(Qv[Qsv == 10]), digit = 2), 70 | "-", 71 | round(max(Qv[Qsv == 10]), digit =2), 72 | " (",round(sum(Wv[Qsv <= 10])),")") 73 | 74 | data <- data.frame(Qv,Wv,Qsv) 75 | 76 | # title <- "" 77 | # subtitle <- "" 78 | 79 | 80 | # adjust geom_jitter position and alpha to make points easier to see. 81 | 82 | ggplot(data, 83 | aes(x = factor(Qsv), 84 | y = Wv, color = Qv)) + 85 | geom_jitter( 86 | position = position_jitter(width = .15), 87 | size = 4, 88 | alpha = .6) + 89 | # geom_text(label = ifelse(ramphs$capacity >= 30000, as.character(ramphs$label),""), hjust = .4, vjust = -1, color = "black") + 90 | theme(legend.text=element_text(size=15), 91 | axis.text=element_text(size=9, colour = "black")) + 92 | xlab(decile.xlab) + 93 | ylab(decile.ylab) + 94 | scale_colour_gradientn(name = scale.name,colours=rev(rainbow(4))) + 95 | scale_x_discrete(labels = c(one.label,two.label,three.label, four.label,five.label,six.label,seven.label, eight.label, nine.label, ten.label)) + 96 | ggtitle(decile.title) + 97 | theme(plot.title = element_text(lineheight=2, face="bold")) + 98 | coord_flip() 99 | } 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Collected Ancient World data sets for R. 2 | 3 | Install with 4 | ```S 5 | devtools::install_github("sfsheath/cawd") 6 | ``` 7 | 8 | See the 'data' directory for current list of R objects provided. And run data() in R to see the same but formatted. 9 | 10 | ## rmarkdown examples of using cawd 11 | 12 | See the inst/rmarkdown directory for source code. The following links are to rendered html files in the gh-pages branch of this repository. 13 | 14 | * http://sebastianheath.com/cawd/inst/rmarkdown/amphitheater-heatmaps.html 15 | * http://sebastianheath.com/cawd/inst/rmarkdown/nearest-amphitheaters.html 16 | * http://sebastianheath.com/cawd/inst/rmarkdown/orbis-rome-near.html 17 | * http://sebastianheath.com/cawd/inst/rmarkdown/torome.html 18 | -------------------------------------------------------------------------------- /cawd.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /data/awmc.persian.extent.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/awmc.persian.extent.sp.rda -------------------------------------------------------------------------------- /data/awmc.roman.empire.117.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/awmc.roman.empire.117.sp.rda -------------------------------------------------------------------------------- /data/awmc.roman.empire.200.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/awmc.roman.empire.200.sp.rda -------------------------------------------------------------------------------- /data/awmc.roman.senatorial.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/awmc.roman.senatorial.sp.rda -------------------------------------------------------------------------------- /data/awmc.roman.territory.60bc.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/awmc.roman.territory.60bc.sp.rda -------------------------------------------------------------------------------- /data/awmc.senatorial.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/awmc.senatorial.sp.rda -------------------------------------------------------------------------------- /data/darmc.rats.1to1500.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/darmc.rats.1to1500.sp.rda -------------------------------------------------------------------------------- /data/darmc.roman.roads.major.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/darmc.roman.roads.major.sp.rda -------------------------------------------------------------------------------- /data/darmc.shipwrecks.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/darmc.shipwrecks.rda -------------------------------------------------------------------------------- /data/darmc.shipwrecks.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/darmc.shipwrecks.sp.rda -------------------------------------------------------------------------------- /data/nomisma.greek.mints.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/nomisma.greek.mints.rda -------------------------------------------------------------------------------- /data/nomisma.greek.mints.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/nomisma.greek.mints.sp.rda -------------------------------------------------------------------------------- /data/nomisma.roman.mints.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/nomisma.roman.mints.rda -------------------------------------------------------------------------------- /data/nomisma.roman.mints.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/nomisma.roman.mints.sp.rda -------------------------------------------------------------------------------- /data/nomisma.roman.provincial.mints.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/nomisma.roman.provincial.mints.rda -------------------------------------------------------------------------------- /data/nomisma.roman.provincial.mints.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/nomisma.roman.provincial.mints.sp.rda -------------------------------------------------------------------------------- /data/orbis.edges.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/orbis.edges.rda -------------------------------------------------------------------------------- /data/orbis.nodes.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/orbis.nodes.rda -------------------------------------------------------------------------------- /data/ramphs.chrono.grps.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/ramphs.chrono.grps.rda -------------------------------------------------------------------------------- /data/ramphs.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/ramphs.rda -------------------------------------------------------------------------------- /data/ramphs.sp.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfsheath/cawd/928f175f6b48e8d14000cdf7bf1a233570bd0485/data/ramphs.sp.rda -------------------------------------------------------------------------------- /inst/rmarkdown/amphitheater-heatmaps.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Roman Amphitheater Heatmaps" 3 | output: html_document 4 | --- 5 | Two ways to make "heatmaps" of the distributioin of Roman Amphitheaters. 6 | 7 | ```{r libraries, warning=F, message=FALSE} 8 | library(curl) 9 | library(ggplot2) 10 | library(raster) 11 | library(rgdal) 12 | library(RColorBrewer) 13 | library(rgl) 14 | library(sp) 15 | library(spatstat) 16 | ``` 17 | 18 | ```{r cawd, warning=F, message=FALSE} 19 | # See http:// 20 | library(cawd) 21 | 22 | #plot Roman empire to confirm load 23 | par(mai=c(0,0,0,0)) 24 | plot(awmc.roman.empire.200.sp) 25 | 26 | # but that's not a very nice projection when done in plot, so... 27 | plot(spTransform(awmc.roman.empire.200.sp, CRS("+init=epsg:3857"))) 28 | 29 | ``` 30 | 31 | ```{r ggplot2, message=FALSE, warning=FALSE} 32 | # ggplot2 makes nice heatmaps and its coord_map() handles WGS84 by default 33 | 34 | #first convert to form ggplot2 likes 35 | fortify(awmc.roman.empire.200.sp) -> awmc.roman.empire.200.gg 36 | 37 | # do a little imputation to create missing data 38 | ramphs$imputed.capacities <- NA 39 | ramphs$imputed.capacities[!(is.na(ramphs$capacity))] <- ramphs[!(is.na(ramphs$capacity)),]$capacity 40 | 41 | lm.imp.1 <- lm ( capacity ~ latitude + 42 | ext.major + ext.minor + arena.major + 43 | arena.minor + arena.major:ext.minor + arena.minor * ext.minor, 44 | data=ramphs ) 45 | 46 | pred.1 <- predict (lm.imp.1, ramphs) 47 | ramphs$imputed.capacities <- ifelse (is.na(ramphs$capacity), pred.1, ramphs$capacity) 48 | ramphs$imputed.capacities[is.na(ramphs$imputed.capacities)] <- 5000 49 | 50 | 51 | # the stat_density2d() call is what makes the heatmap 52 | ggplot(ramphs, aes(x = longitude, y = latitude)) + 53 | coord_map() + 54 | geom_polygon(data=awmc.roman.empire.200.gg,aes(x=long, y=lat,group=group), colour="purple", fill = "purple", alpha = .5) + 55 | geom_density2d(aes(fill = ..level..),kernel = "cosine",) + 56 | geom_point( colour = 'black', size = 2) + 57 | geom_point(aes(size = capacity), colour = 'red') + 58 | scale_fill_gradientn(colours=rev(brewer.pal(7,"Spectral"))) + 59 | theme_bw() + 60 | geom_tile 61 | ``` 62 | 63 | ```{r spatstat, message=FALSE, warning=FALSE} 64 | # we can also use spatstat to make the heat map 65 | 66 | # yes, I could calculate these bounds 67 | longitudeExtent <- c(-9, 44) 68 | latitudeExtent <- c(31, 56) 69 | 70 | # first make a spatstat ppp object with a rectangular owin (that's the limits of the point pattern) 71 | tmp.ppp <- as.ppp(dplyr::select(ramphs, longitude,latitude),owin(longitudeExtent,latitudeExtent)) 72 | 73 | # expand owin for analysis by calculating the convex hull of the amphitheaters. 74 | # but expand it a little bit so heat map doesn't cut off too much 75 | 76 | tmp.hull <- spatstat::convexhull(tmp.ppp) 77 | # while we're at it, plot the hull 78 | par(mai=c(0,0,0,0)) # do I really have to repeat this? 79 | plot(awmc.roman.empire.200.sp) 80 | plot(tmp.hull, add=T) 81 | 82 | tmp.owin <- expand.owin(tmp.hull, distance = .8) 83 | 84 | # so now we can make ramphs.ppp with a decent owin 85 | ramphs.ppp <- as.ppp(dplyr::select(ramphs, longitude,latitude, imputed.capacities),W = tmp.owin) 86 | 87 | # make a grid of the density weighted by the imputed capacity 88 | # but right now, the imputed capacity is way too fancy a term 89 | # i'm just filling in 10K for when I don't have that info 90 | density <- density(ramphs.ppp, weights = ramphs$imputed.capacities) 91 | raster(density) -> r 92 | projection(r) <- CRS("+proj=longlat +datum=WGS84") 93 | plot(r) 94 | plot(awmc.roman.empire.200.sp, add = T) 95 | 96 | # and in 3d sort of 97 | persp(r,phi = 30, 98 | theta = -30, 99 | expand = .25, 100 | border = NA, 101 | shade = .6) # yeah, needs a color scheme. i'll return to that... 102 | ``` 103 | 104 | -------------------------------------------------------------------------------- /inst/rmarkdown/darmc-rat-maps.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Heatmap of Archaeologicaly Attested Rat Remains (AD 1-500)" 3 | output: html_document 4 | --- 5 | Data from http://darmc.harvard.edu/icb/icb.do?keyword=k40248&pageid=icb.page601659 as loaded into http://github.com/sfsheath/cawd . 6 | 7 | 8 | ```{r libraries} 9 | library(ggplot2) 10 | library(RColorBrewer) 11 | library(sp) 12 | ``` 13 | 14 | ```{r cawd, warning=F, message=FALSE} 15 | # See http://github.com/sfsheath/cawd 16 | library(cawd) 17 | ``` 18 | 19 | ```{r ggplot2} 20 | # ggplot2 makes nice heatmaps and its coord_map() handles WGS84 by default 21 | 22 | #first convert roman outline to form ggplot2 likes 23 | fortify(awmc.roman.empire.200.sp) -> awmc.roman.empire.200.gg 24 | 25 | # the stat_density2d() call is what makes the heatmap 26 | ggplot(as.data.frame(darmc.rats.1to1500.sp[darmc.rats.1to1500.sp$latitude > 0,]), aes(x = longitude, y = latitude)) + 27 | coord_map() + 28 | stat_density2d(aes(fill = ..level..), alpha=0.5, geom="polygon") + 29 | scale_fill_gradientn(colours=rev(brewer.pal(7,"Spectral"))) + 30 | geom_path(data=awmc.roman.empire.200.gg,aes(x=long, y=lat,group=group), colour="black") + 31 | geom_point(alpha = .5, colour = 'red') 32 | ``` 33 | ## Credits 34 | Use the R package documentation to show credits for data. (I welcome feedback on whether or not this approach works.) 35 | ```{r credits, message = T} 36 | library(printr) 37 | # help(darmc.rats.1to1500.sp) 38 | help(darmc.rats.1to1500.sp) 39 | 40 | help(awmc.roman.empire.200.sp) 41 | ``` 42 | -------------------------------------------------------------------------------- /inst/rmarkdown/margin-histograms.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Marginal Histograms" 3 | output: html_document 4 | --- 5 | 6 | Code adapted from http://www.r-bloggers.com/ggextra-r-package-for-adding-marginal-histograms-to-ggplot2/ 7 | 8 | ```{r, warning=FALSE, message=FALSE } 9 | 10 | #libraries 11 | library(ggplot2) 12 | library(ggExtra) 13 | 14 | # data 15 | library(cawd) # See http://github.com/sfsheath/cawd 16 | 17 | 18 | # create a ggplot2 scatterplot of exterior dimensions of Roman amphitheaters (meters) 19 | p <- ggplot(ramphs, aes(ext.major, ext.minor)) + geom_point() + theme_classic() 20 | # add marginal histograms 21 | ggExtra::ggMarginal(p, type = "histogram") 22 | -------------------------------------------------------------------------------- /inst/rmarkdown/nearest-amphitheaters.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Calculating and Using Distances between Roman Amphitheaters" 3 | output: html_document 4 | --- 5 | A quick demo of calcuating distances between points and then working with that data. Makes it through thinking of distance pairs as a network. Feel free to fork and improve. 6 | ```{r wholething, warning=FALSE, message= F} 7 | # libraries 8 | library(curl) 9 | library(ggplot2) 10 | library(igraph) 11 | library(sp) 12 | library(tidyr) 13 | 14 | # load amphitheater data 15 | library(cawd) 16 | 17 | #generate distances of all amphitheaters to all other amphitheaters 18 | ramphs.dists <- spDists(ramphs.sp,ramphs.sp,longlat = TRUE) 19 | 20 | # this is in the form of a matrix 21 | #print the distance between the Dura and Arles Amphitheaters 22 | ramphs.dists[1,2] 23 | 24 | # but let's use names 25 | colnames(ramphs.dists) <- ramphs$id 26 | rownames(ramphs.dists) <- ramphs$id 27 | 28 | # now print distane between Arles Amphitheater and Lyon Amphitheater 29 | ramphs.dists["arlesAmphitheater", "lyonAmphitheater"] 30 | 31 | # we also have useless info that amphitheaters are 0Km from themselves 32 | ramphs.dists["arlesAmphitheater", "arlesAmphitheater"] 33 | 34 | # Would be nice to have a d.f in the form from,to,km 35 | as.data.frame(ramphs.dists) -> ramphs.dists.df 36 | 37 | #add column of names, in anticipation of using gather() 38 | cbind(from = ramphs$id,ramphs.dists.df) -> ramphs.dists.df 39 | 40 | gather(ramphs.dists.df, to, km, 2:dim(ramphs.dists.df)[2]) -> ramphs.dists.df 41 | 42 | # data now in nice columns but... 43 | # we still have the 0Km rows. 44 | head(ramphs.dists.df) 45 | 46 | #set phasers to kill... 47 | ramphs.dists.df[ramphs.dists.df$km > 0,] -> ramphs.dists.df 48 | 49 | # yay, they're gone 50 | head(ramphs.dists.df) 51 | 52 | # printing pairs is wordier than using the matrix 53 | ramphs.dists.df$km[ramphs.dists.df$from == 'arlesAmphitheater' & ramphs.dists.df$to == 'lyonAmphitheater'] 54 | # we record both directions, that's probably not a problem but do keep it in mind 55 | ramphs.dists.df$km[ramphs.dists.df$from == 'lyonAmphitheater' & ramphs.dists.df$to == 'arlesAmphitheater'] 56 | 57 | #reasonably straigtforward to find closest neighbor (target for improvement) 58 | ramphs.dists.df[ramphs.dists.df$from == "duraEuroposAmphitheater",] -> tmp.df 59 | as.character(tmp.df$to[which.min(tmp.df$km)]) # avoid extra factor output w/as.character() 60 | 61 | # and note that we can think of this df as edges of a network 62 | graph.data.frame(ramphs.dists.df, directed = TRUE) -> ramphs.dists.nw 63 | 64 | # let's see groups of amphitheaters close to each other 65 | subgraph.edges(ramphs.dists.nw, eids = E(ramphs.dists.nw)[km < 99]) -> close.amphitheaters.nw 66 | close.amphitheaters.nw 67 | par(mai = c(0,0,0,0)) 68 | plot(close.amphitheaters.nw, 69 | edge.arrow.size = 0, 70 | vertex.size = 2, 71 | vertex.label.cex = .3) 72 | 73 | # now let's look for "close" amphitheaters with high network degree. 74 | # those are deeply integrated into dense groupings. 75 | 76 | degree(close.amphitheaters.nw) -> tmp.nw 77 | 78 | set.vertex.attribute(close.amphitheaters.nw, 79 | name = "degree", 80 | index = V(close.amphitheaters.nw), 81 | value = tmp.nw) -> close.amphitheaters.nw 82 | 83 | summary(V(close.amphitheaters.nw)$degree) 84 | 85 | # top quartile 86 | summary(V(close.amphitheaters.nw)$degree)[5] 87 | 88 | # print the top quartile 89 | V(close.amphitheaters.nw)[degree >= summary(V(close.amphitheaters.nw)$degree)[5]] 90 | # next up, exploring where those are (Italy, anyone?) 91 | ``` 92 | 93 | -------------------------------------------------------------------------------- /inst/rmarkdown/orbis-rome-near.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Using Orbis to Identify Amphitheaters Close to Rome" 3 | output: 4 | html_document: 5 | pandoc_args: [ 6 | "+RTS", "-K64m", 7 | "-RTS" 8 | ] 9 | --- 10 | 11 | ## Introduction 12 | * The basemap is Johan Åhlfeldt's "Imperium" map as made for his [Digital Atlas of the Roman Empire](http://dare.ht.lu.se). The URL pattern for accessing those tiles is 13 | * The Rome boundary is courtesy of [UNC's Ancient World Mapping Center](http://awmc.unc.edu/). 14 | * Sites in the Stanford Orbis model of Roman connectivity are then plotted according to their supplied latitude and longitude. That data is available at http://purl.stanford.edu/mn425tz9757 . The sites in 90th percentile of closeness to Rome as calculated using the igraph R function shortest.paths() are colored in blue. Those farther away are in red. 15 | * The convex hull of the closest sites is plotted. It was calculated using the gConvexHull() function from the rgeos package. 16 | * That convex hull is used to identify the Roman amphitheaters that lie within it. The over() function in the sp package handles that. These amphitheaters are then plotted in green. 17 | 18 | 19 | ## Map of Amphitheaters "Close" to Rome as Defined by the Stanford Orbis Model of Connectivity in the Roman World 20 | 21 | ```{r map, warning=FALSE, message=FALSE} 22 | #load libraries 23 | library(curl) 24 | library(leaflet) 25 | library(igraph) 26 | library(rgeos) 27 | library(sp) 28 | 29 | #load data sets 30 | library(cawd) 31 | 32 | #setting the network 33 | o.nw <- graph.data.frame(orbis.edges, vertices=orbis.nodes, directed=TRUE) 34 | 35 | #add the x and y back in. with the NA's set to 0 36 | #set.vertex.attribute(o.nw,name = "x", index = as.character(orbis.nodes$id), value = orbis.nodes$x) -> o.nw 37 | #set.vertex.attribute(o.nw,name = "y", index = as.character(orbis.nodes$id), value = orbis.nodes$y) -> o.nw 38 | 39 | #set.vertex.attribute(o.nw,"x",index = V(o.nw)[is.na(x)], 0) -> o.nw 40 | #set.vertex.attribute(o.nw,"y",index = V(o.nw)[is.na(y)], 0) -> o.nw 41 | 42 | #finding the shortest paths referring to Roma, by expenses, and assigning to a new object 43 | shortest.paths(o.nw,V(o.nw)[title == "Roma"], weights = E(o.nw)$expense) -> o.nw.torome 44 | o.nw <- set.vertex.attribute(o.nw, "torome", index = V(o.nw), value = o.nw.torome) 45 | 46 | #new dataframe that has two columns: the label (name of place) and the distance to Rome 47 | data.frame(label = V(o.nw)$title, torome = V(o.nw)$torome) -> tmp.df 48 | 49 | quantile(V(o.nw)$torome, probs = 0:60/60)[5] -> q.num 50 | 51 | V(o.nw)$title[V(o.nw)$torome >= q.num] -> o.above.q 52 | data.frame(title = o.above.q) -> o.above.q 53 | merge(o.above.q,orbis.nodes, by.x = "title", by.y = "title") -> o.above.q 54 | #o.above.q <- o.above.q[!is.na(o.above.q$x),] 55 | o.above.q.sp <- o.above.q 56 | coordinates(o.above.q.sp) <- ~ longitude + latitude 57 | proj4string(o.above.q.sp) <- CRS("+proj=longlat +datum=WGS84") 58 | 59 | V(o.nw)$title[V(o.nw)$torome < q.num] -> o.below.q 60 | data.frame(title = o.below.q) -> o.below.q 61 | merge(o.below.q,orbis.nodes, by.x = "title", by.y = "title") -> o.below.q 62 | #o.below.q <- o.below.q[!is.na(o.below.q$x),] 63 | o.below.q.sp <- o.below.q[o.below.q$latitude > 0,] 64 | coordinates(o.below.q.sp) <- ~ longitude + latitude 65 | proj4string(o.below.q.sp)=CRS("+proj=longlat +datum=WGS84") 66 | 67 | 68 | gConvexHull(o.below.q.sp) -> o.below.hull.sp 69 | proj4string(o.below.hull.sp)=CRS("+proj=longlat +datum=WGS84") 70 | sp::over(ramphs.sp,o.below.hull.sp) -> these.ramphs 71 | ramphs.sp[!is.na(these.ramphs),] -> these.ramphs.sp 72 | proj4string(these.ramphs.sp)=CRS("+proj=longlat +datum=WGS84") 73 | 74 | leaflet() %>% addTiles(urlTemplate = "http://pelagios.dme.ait.ac.at/tilesets/imperium//{z}/{x}/{y}.png", 75 | attribution = "Digital Atlas Roman Empire", tileOptions(opacity= .3)) %>% 76 | addPolygons(data = awmc.roman.empire.200.sp, color = 'black', fillOpacity = .05, stroke = F, ) %>% 77 | addPolygons(data = o.below.hull.sp, color = 'red', fillOpacity = .1, stroke = F) %>% 78 | addCircleMarkers(data = o.above.q.sp, color = "red", popup =o.above.q.sp$label, radius = 1) %>% 79 | addCircleMarkers(data = o.below.q.sp, popup =o.below.q.sp$label, radius = 1) %>% 80 | addCircleMarkers(data = these.ramphs.sp, color = "green", popup = these.ramphs.sp$label, radius = 1) 81 | ``` 82 | -------------------------------------------------------------------------------- /inst/rmarkdown/torome.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: Examples of Expanding the Orbis Network out from Rome 3 | output: 4 | html_document 5 | --- 6 | 7 | ## Introduction 8 | 9 | A few examples of calculating graph distance from Rome according to http://orbis.stanford.edu . Data from http://purl.stanford.edu/mn425tz9757 . 10 | 11 | Adapted from code and comments developed in [NYU/ISAW's](http://isaw.nyu.edu) "Mapping and Data Visualization" Spring 2015 seminar. 12 | 13 | 14 | ## Load some libraries 15 | 16 | ```{r libraries, message=FALSE, warning=FALSE} 17 | #load libraries 18 | library(curl) 19 | library(igraph) 20 | ``` 21 | 22 | ## Load data and make graph 23 | ```{r data, message = FALSE, warning=FALSE} 24 | # cawd is an R package of "Collected Ancient World Data" 25 | # http://github.com/sfsheath/cawd 26 | library(cawd) 27 | 28 | # igraph like a 'label' column 29 | orbis.nodes$label <- orbis.nodes$title 30 | 31 | #setting the network 32 | o.nw <- graph.data.frame(orbis.edges, vertices=orbis.nodes, directed=TRUE) 33 | 34 | # this now plot()able but it's so big that it's too messy to be useful 35 | ``` 36 | 37 | ## Calculate shortest paths to Rome 38 | ```{r calculate, message=FALSE, warning=FALSE} 39 | #finding the shortest paths referring to Roma, by expenses, and assigning to a new object 40 | shortest.paths(o.nw,V(o.nw)[V(o.nw)$title == "Roma"], weights = E(o.nw)$expense) -> o.nw.torome 41 | 42 | 43 | o.nw <- set.vertex.attribute(o.nw, "torome", index = V(o.nw), value = o.nw.torome) 44 | ``` 45 | 46 | ## Divide into equal fiftieths (or choose your number) 47 | ```{r quartiles} 48 | # first print it 49 | quantile(V(o.nw)$torome, probs = 1:50/50) 50 | 51 | # now keep it for future use 52 | quantile(V(o.nw)$torome, probs = 1:50/50) -> breaks 53 | 54 | ``` 55 | 56 | ## Now subgraph by various values of torome 57 | This could be turned into a trivial function but I just copy-and-paste for clarity. For now... 58 | 59 | In all of the following examples, the V() function, which lists verteces in an igraph graph, is used to select verteces accoring to their "distance" from Rome accoring to the Orbis graph. 60 | 61 | Note that I am just increasing the index into 'breaks[]'. 62 | 63 | ### Very, very "close" 64 | ```{r one, message=FALSE, warning=FALSE} 65 | 66 | tmp.nw <- subgraph(o.nw, v = V(o.nw)[torome <= breaks[1]]) 67 | 68 | plot(tmp.nw, 69 | edge.arrow.size = 0, 70 | vertex.label.cex = .6 71 | ) 72 | ``` 73 | 74 | ### Very "close" 75 | ```{r two, message=FALSE, warning=FALSE} 76 | 77 | tmp.nw <- subgraph(o.nw, v = V(o.nw)[torome <= breaks[2]]) 78 | 79 | plot(tmp.nw, 80 | edge.arrow.size = 0, 81 | vertex.label.cex = .6 82 | ) 83 | ``` 84 | 85 | ### "close", now with label color = 'red' 86 | ```{r three, message=FALSE, warning=FALSE} 87 | 88 | tmp.nw <- subgraph(o.nw, v = V(o.nw)[torome <= breaks[3]]) 89 | 90 | plot(tmp.nw, 91 | edge.arrow.size = 0, 92 | vertex.label.cex = .6, 93 | vertex.label.color = 'red' 94 | ) 95 | ``` 96 | 97 | ### Getting messy so smaller vertex.size... 98 | ```{r four, message=FALSE, warning=FALSE} 99 | 100 | tmp.nw <- subgraph(o.nw, v = V(o.nw)[torome <= breaks[5]]) 101 | 102 | plot(tmp.nw, 103 | edge.arrow.size = 0, 104 | vertex.label.cex = .6, 105 | vertex.size = 2 106 | ) 107 | ``` 108 | 109 | ### Last one, the closest 20%... 110 | ```{r five, message=FALSE, warning=FALSE} 111 | 112 | tmp.nw <- subgraph(o.nw, v = V(o.nw)[torome <= breaks[10]]) 113 | 114 | plot(tmp.nw, 115 | edge.arrow.size = 0, 116 | vertex.label.cex = .6, 117 | vertex.size = 2 118 | ) 119 | ``` 120 | 121 | 122 | ## Next up, turning these into maps... 123 | 124 | -------------------------------------------------------------------------------- /inst/scripts/collect.awmc.R: -------------------------------------------------------------------------------- 1 | library(devtools) 2 | library(maptools) 3 | library(rgdal) 4 | 5 | # the shapefile import gives an error so go from my geojson version 6 | # and yeah, how ugly is it that I need the full pathname 7 | 8 | tmp.sp <- readOGR(dsn = "/Users/sfsh/Documents/roman-maps/roman_empire_bc_60_extent.geojson",layer = "OGRGeoJSON", disambiguateFIDs = T ) 9 | # there are many small polygons. remove them. 10 | awmc.roman.territory.60bc.sp <- tmp.sp[tmp.sp$AREA > .1,] 11 | use_data(awmc.roman.territory.60bc.sp, overwrite = T) 12 | 13 | shapefile <- readShapeSpatial('~/Documents/roman-shapefiles/roman_empire_ad_117_extent.shp') 14 | proj4string(shapefile) <- CRS("+proj=longlat +datum=WGS84") 15 | shapefile -> awmc.roman.empire.117.sp 16 | use_data(awmc.roman.empire.117.sp, overwrite = T) 17 | 18 | shapefile <- readShapeSpatial('~/Documents/roman-shapefiles/roman_empire_ad_200_extent.shp') 19 | proj4string(shapefile) <- CRS("+proj=longlat +datum=WGS84") 20 | shapefile -> awmc.roman.empire.200.sp 21 | use_data(awmc.roman.empire.200.sp, overwrite = T) 22 | 23 | shapefile <- readShapePoly("~/Documents/awmc-maps/political_shading/persian_extent.shp") 24 | proj4string(shapefile) <- CRS("+proj=longlat +datum=WGS84") 25 | shapefile -> awmc.persian.extent.sp 26 | use_data(awmc.persian.extent.sp, overwrite = T) 27 | 28 | shapefile <- readShapePoly("~/Documents/awmc-maps/political_shading/senatorial_province.shp") 29 | proj4string(shapefile) <- CRS("+proj=longlat +datum=WGS84") 30 | shapefile -> awmc.roman.senatorial.sp 31 | use_data(awmc.roman.senatorial.sp, overwrite = T) 32 | 33 | rm(shapefile) 34 | 35 | -------------------------------------------------------------------------------- /inst/scripts/collect.darmc.rats.1to1500.R: -------------------------------------------------------------------------------- 1 | library(devtools) 2 | library(maptools) 3 | library(rgdal) 4 | 5 | # the shapefile import gives an error so go from my geojson version 6 | # and yeah, how ugly is it that I need the full pathname 7 | 8 | shapefile <- readShapeSpatial('~/Documents/darmc/rats_release.shp') 9 | proj4string(shapefile) <- CRS("+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") 10 | darmc.rats.1to1500.sp <- spTransform(shapefile, CRS("+proj=longlat +datum=WGS84")) 11 | names(darmc.rats.1to1500.sp) <- c("title", 12 | "latitude","longitude", 13 | "Q_GEO", 14 | "start.date","end.date", 15 | "Q_DATE","REMS", 16 | "count", 17 | "Q_CONTEXT", 18 | "comment", 19 | "bibliographic.citation") 20 | use_data(darmc.rats.1to1500.sp, overwrite = T) 21 | 22 | 23 | shapefile <- readShapeSpatial('~/Documents/darmc/roman_roads_v2008.shp') 24 | proj4string(shapefile) <- '+proj=lcc +lat_1=43.0 +lat_2=62.0 +lat_0=30 +lon_0=10 +x_0=0 +y_0=0 +ellps=intl +units=m +no_defs' 25 | darmc.roman.roads.sp <- spTransform(shapefile, CRS("+proj=longlat +datum=WGS84")) 26 | darmc.roman.roads.major.sp <- darmc.roman.roads.sp[darmc.roman.roads.sp$CLASS == "Major Road",] 27 | 28 | use_data(darmc.roman.roads.major.sp, overwrite = T) 29 | 30 | rm(shapefile) 31 | 32 | -------------------------------------------------------------------------------- /inst/scripts/collect.darmc.shipwrecks.R: -------------------------------------------------------------------------------- 1 | library(devtools) 2 | library(maptools) 3 | library(rgdal) 4 | library(sp) 5 | 6 | # assumes excel spreadsheet has been download and exported to csv. change file names as necessary 7 | read.csv("~/Documents/darmc//darmc.shipwrecks.csv") -> darmc.shipwrecks 8 | 9 | darmc.shipwrecks <- darmc.shipwrecks[1:28] # drop any extra columns 10 | 11 | names(darmc.shipwrecks) <- c("title", 12 | "title.other", 13 | "X2008.Wreck.ID", 14 | "latitude", 15 | "longitude", 16 | "Geo.Q", 17 | "start.date", 18 | "end.date", 19 | "Date.Q", 20 | "Depth", 21 | "Depth.Q", 22 | "Year.Found", 23 | "Year.Found.Q", 24 | "Cargo.1", 25 | "Type.1", 26 | "Cargo.2", 27 | "Type.2", 28 | "Cargo.3", 29 | "Type.3", 30 | "Other.Cargo", 31 | "Gear", 32 | "Estimated.Capacity", 33 | "comment", 34 | "Length", 35 | "Width", 36 | "Size.Estimate.Q", 37 | "Parker.reference", 38 | "Bibliography.and.Notes" 39 | ) 40 | 41 | darmc.shipwrecks.sp <- darmc.shipwrecks[complete.cases(darmc.shipwrecks[4:5]),] 42 | 43 | coordinates(darmc.shipwrecks.sp) <- ~ longitude + latitude 44 | proj4string(darmc.shipwrecks.sp) <- CRS("+proj=longlat +datum=WGS84") 45 | 46 | use_data(darmc.shipwrecks, overwrite = T) 47 | use_data(darmc.shipwrecks.sp, overwrite = T) 48 | -------------------------------------------------------------------------------- /inst/scripts/collect.nomisma.R: -------------------------------------------------------------------------------- 1 | # first go at script to load nomisma.org data into cawd. 2 | library(devtools) 3 | library(sp) 4 | library(SPARQL) 5 | 6 | url <- "http://nomisma.org/query" 7 | 8 | ns = c('geo','', 9 | 'nmo','', 10 | 'pleiades','', 12 | 'spatial','', 13 | 'xsd','') 14 | 15 | 16 | # greek (turn parts of these chunks into functions) 17 | sparql.response <- SPARQL(url = url, ns = ns, 18 | query = ' 19 | PREFIX rdf: 20 | PREFIX dcterms: 21 | PREFIX geo: 22 | PREFIX nm: 23 | PREFIX nmo: 24 | PREFIX skos: 25 | PREFIX spatial: 26 | PREFIX xsd: 27 | SELECT ?title ?uri ?latitude ?longitude ?pleiades WHERE { 28 | ?uri a nmo:Mint; 29 | dcterms:isPartOf nm:greek_numismatics ; 30 | skos:prefLabel ?title; 31 | geo:location ?loc . 32 | OPTIONAL {?uri skos:closeMatch ?pleiades} 33 | ?loc geo:lat ?latitude ; 34 | geo:long ?longitude . 35 | FILTER (langMatches(lang(?title), "en") && regex(str(?pleiades), "pleiades.stoa.org" )) 36 | }' 37 | ) 38 | 39 | nomisma.greek.mints <- sparql.response$results 40 | 41 | # remove host and path from Pleiades ID 42 | nomisma.greek.mints$pleiades <- sub('pleiades:/','',nomisma.greek.mints$pleiades, fixed = T) 43 | 44 | nomisma.greek.mints$title <- gsub('"','',nomisma.greek.mints$title, fixed = T) 45 | nomisma.greek.mints$title <- gsub('@en','',nomisma.greek.mints$title, fixed = T) 46 | 47 | nomisma.greek.mints$uri <- gsub('<','',nomisma.greek.mints$uri, fixed = T) 48 | nomisma.greek.mints$uri <- gsub('>','',nomisma.greek.mints$uri, fixed = T) 49 | 50 | 51 | nomisma.greek.mints.sp <- nomisma.greek.mints 52 | coordinates(nomisma.greek.mints.sp) <- ~ longitude + latitude 53 | proj4string(nomisma.greek.mints.sp) <- CRS("+proj=longlat +datum=WGS84") 54 | 55 | use_data(nomisma.greek.mints, overwrite = T) 56 | use_data(nomisma.greek.mints.sp, overwrite = T) 57 | 58 | # roman 59 | sparql.response <- SPARQL(url = url, ns = ns, 60 | query = ' 61 | PREFIX rdf: 62 | PREFIX dcterms: 63 | PREFIX geo: 64 | PREFIX nm: 65 | PREFIX nmo: 66 | PREFIX skos: 67 | PREFIX spatial: 68 | PREFIX xsd: 69 | SELECT ?title ?uri ?latitude ?longitude ?pleiades WHERE { 70 | ?uri a nmo:Mint; 71 | dcterms:isPartOf nm:roman_numismatics ; 72 | skos:prefLabel ?title; 73 | geo:location ?loc . 74 | OPTIONAL {?uri skos:closeMatch ?pleiades} 75 | ?loc geo:lat ?latitude ; 76 | geo:long ?longitude . 77 | FILTER (langMatches(lang(?title), "en") && regex(str(?pleiades), "pleiades.stoa.org" )) 78 | }' 79 | ) 80 | 81 | nomisma.roman.mints <- sparql.response$results 82 | 83 | # remove host and path from Pleiades ID 84 | nomisma.roman.mints$pleiades <- sub('pleiades:/','',nomisma.roman.mints$pleiades, fixed = T) 85 | 86 | nomisma.roman.mints$title <- gsub('"','',nomisma.roman.mints$title, fixed = T) 87 | nomisma.roman.mints$title <- gsub('@en','',nomisma.roman.mints$title, fixed = T) 88 | 89 | nomisma.roman.mints$uri <- gsub('<','',nomisma.roman.mints$uri, fixed = T) 90 | nomisma.roman.mints$uri <- gsub('>','',nomisma.roman.mints$uri, fixed = T) 91 | 92 | nomisma.roman.mints.sp <- nomisma.roman.mints 93 | coordinates(nomisma.roman.mints.sp) <- ~ longitude + latitude 94 | proj4string(nomisma.roman.mints.sp) <- CRS("+proj=longlat +datum=WGS84") 95 | 96 | use_data(nomisma.roman.mints, overwrite = T) 97 | use_data(nomisma.roman.mints.sp, overwrite = T) 98 | 99 | # roman provincial. the nomisma data is clearly incomplete as only 4 mints are listed. needs work on that end. 100 | sparql.response <- SPARQL(url = url, ns = ns, 101 | query = ' 102 | PREFIX rdf: 103 | PREFIX dcterms: 104 | PREFIX geo: 105 | PREFIX nm: 106 | PREFIX nmo: 107 | PREFIX skos: 108 | PREFIX spatial: 109 | PREFIX xsd: 110 | SELECT ?title ?uri ?latitude ?longitude ?pleiades WHERE { 111 | ?uri a nmo:Mint; 112 | dcterms:isPartOf nm:roman_provincial_numismatics ; 113 | skos:prefLabel ?title; 114 | geo:location ?loc . 115 | OPTIONAL {?uri skos:closeMatch ?pleiades} 116 | ?loc geo:lat ?latitude ; 117 | geo:long ?longitude . 118 | FILTER (langMatches(lang(?title), "en") && regex(str(?pleiades), "pleiades.stoa.org" )) 119 | }' 120 | ) 121 | 122 | nomisma.roman.provincial.mints <- sparql.response$results 123 | 124 | # remove host and path from Pleiades ID 125 | nomisma.roman.provincial.mints$pleiades <- sub('pleiades:/','',nomisma.roman.provincial.mints$pleiades, fixed = T) 126 | 127 | nomisma.roman.provincial.mints$title <- gsub('"','',nomisma.roman.provincial.mints$title, fixed = T) 128 | nomisma.roman.provincial.mints$title <- gsub('@en','',nomisma.roman.provincial.mints$title, fixed = T) 129 | 130 | nomisma.roman.provincial.mints$uri <- gsub('<','',nomisma.roman.provincial.mints$uri, fixed = T) 131 | nomisma.roman.provincial.mints$uri <- gsub('>','',nomisma.roman.provincial.mints$uri, fixed = T) 132 | 133 | 134 | nomisma.roman.provincial.mints.sp <- nomisma.roman.provincial.mints 135 | coordinates(nomisma.roman.provincial.mints.sp) <- ~ longitude + latitude 136 | proj4string(nomisma.roman.provincial.mints.sp) <- CRS("+proj=longlat +datum=WGS84") 137 | 138 | use_data(nomisma.roman.provincial.mints, overwrite = T) 139 | use_data(nomisma.roman.provincial.mints.sp, overwrite = T) 140 | -------------------------------------------------------------------------------- /inst/scripts/collect.orbis.R: -------------------------------------------------------------------------------- 1 | library(curl) 2 | library(devtools) 3 | library(jsonlite) 4 | 5 | # Script to load orbis nodes and edges 6 | 7 | # I think the best data is available via the API 8 | fromJSON("http://orbis.stanford.edu/api/sites", simplifyVector = F) -> tmp.orbis 9 | 10 | tmp.o.id <- vector() 11 | for (i in 1:length(tmp.orbis)) { tmp.o.id[i] <- tmp.orbis[[i]][[2]][[1]] } 12 | 13 | tmp.o.name <- vector() 14 | for (i in 1:length(tmp.orbis)) { tmp.o.name[i] <- tmp.orbis[[i]][[2]][[2]] } 15 | 16 | tmp.o.latitude <- numeric() 17 | for (i in 1:length(tmp.orbis)) { tmp.o.latitude[i] <- as.double(ifelse(is.null(tmp.orbis[[i]][[2]][[3]]),"0",tmp.orbis[[i]][[2]][[3]])) } 18 | 19 | tmp.o.longitude <- numeric() 20 | for (i in 1:length(tmp.orbis)) { tmp.o.longitude[i] <- as.double(ifelse(is.null(tmp.orbis[[i]][[2]][[4]]),"0",tmp.orbis[[i]][[2]][[4]])) } 21 | 22 | tmp.o.pleiades <- vector() 23 | for (i in 1:length(tmp.orbis)) { tmp.o.pleiades[i] <- tmp.orbis[[i]][[2]][[5]] } 24 | 25 | tmp.o.contributor <- vector() 26 | for (i in 1:length(tmp.orbis)) { tmp.o.contributor[i] <- ifelse(is.null(tmp.orbis[[i]][[2]][[6]]),"",tmp.orbis[[i]][[2]][[6]]) } 27 | 28 | tmp.o.isport <- vector() 29 | for (i in 1:length(tmp.orbis)) { tmp.o.isport[i] <- tmp.orbis[[i]][[2]][[7]] } 30 | 31 | tmp.o.rank <- vector() 32 | for (i in 1:length(tmp.orbis)) { tmp.o.rank[i] <- tmp.orbis[[i]][[2]][[8]] } 33 | 34 | 35 | # returns {orbis_id, name, lat, lon, Pleiades ID if known, contributor, isPort (t/f), size rank(6-10)} 36 | orbis.nodes <- data.frame(id = tmp.o.id, 37 | title = tmp.o.name, 38 | latitude = tmp.o.latitude, 39 | longitude = tmp.o.longitude, 40 | pleiades = tmp.o.pleiades, 41 | contributor = tmp.o.contributor, 42 | is.port = tmp.o.isport, 43 | size.rank = tmp.o.rank, 44 | stringsAsFactors = FALSE) 45 | 46 | orbis.nodes$id <- as.integer(orbis.nodes$id) 47 | #orbis.nodes$latitude <- as.double(orbis.nodes$latitude) 48 | #orbis.nodes$longitude <- as.double(orbis.nodes$longitude) 49 | orbis.nodes$size.rank <- as.integer(orbis.nodes$size.rank) 50 | orbis.nodes$is.port = ifelse(orbis.nodes$is.port == 't', TRUE, FALSE) 51 | 52 | # these are nodes that appear in the orbis.edges data loaded below but which are not available in the API 53 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50038,title = "x",latitude = 36.039,longitude = 34.534,pleiades = "",contributor = "", is.port = F,size.rank = 6)) 54 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50317,title = "Portus",latitude = 41.78,longitude = 12.258,pleiades = "", contributor = "", is.port = T, size.rank = 8)) 55 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50457,title = "Aufidus",latitude = 41.36,longitude = 16.21,pleiades = "442485",contributor = "", is.port = F,size.rank = 0)) 56 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50522,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 57 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50572,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 58 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50721,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 59 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50726,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 60 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50727,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 61 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50730,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 62 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50731,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 63 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50732,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 64 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50733,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 65 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50735,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 66 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50736,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 67 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50737,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 68 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50738,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 69 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50739,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 70 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50745,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 71 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50746,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 72 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50747,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 73 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50748,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 74 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50749,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 75 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50750,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 76 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50751,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 77 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50752,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 78 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50753,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 79 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50754,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 80 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50757,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 81 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50760,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 82 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50763,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 83 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50764,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 84 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50765,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 85 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50766,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 86 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50767,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 87 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50768,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 88 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50769,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 89 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50770,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 90 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50771,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 91 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50772,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 92 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50773,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 93 | orbis.nodes <- rbind(orbis.nodes,data.frame(id = 50774,title = "",latitude = 0,longitude = 0,pleiades = "",contributor = "", is.port = F,size.rank = 0)) 94 | 95 | # A number of the lat/long pairs in the API data are missing (so zeroed on collection), reversed or otherwise incorrect. Fix these: 96 | orbis.nodes$latitude[orbis.nodes$title == "Amorgos"] <- 36.83 # reversed 97 | orbis.nodes$longitude[orbis.nodes$title == "Amorgos"] <- 25.9 98 | 99 | orbis.nodes$latitude[orbis.nodes$title == "Anaphe"] <- 36.34982 # reversed 100 | orbis.nodes$longitude[orbis.nodes$title == "Anaphe"] <- 25.85407 101 | 102 | orbis.nodes$latitude[orbis.nodes$title == "Andros"] <- 37.85 # reversed 103 | orbis.nodes$longitude[orbis.nodes$title == "Andros"] <- 24.86 104 | 105 | orbis.nodes$latitude[orbis.nodes$title == "Berenice"] <- 32.116667 # from wikipedia 106 | orbis.nodes$longitude[orbis.nodes$title == "Berenice"] <- 20.066667 107 | # and while we're at it, add the pleiades id 108 | orbis.nodes$pleiades[orbis.nodes$title == "Berenice"] <- 373757 109 | 110 | orbis.nodes$latitude[orbis.nodes$title == "Isthmia"] <- 37.91573 # reversed and incorrect (wrong side of canal). ll from google maps click 111 | orbis.nodes$longitude[orbis.nodes$title == "Isthmia"] <- 22.993024 112 | 113 | orbis.nodes$latitude[orbis.nodes$title == "Tenos"] <- 37.553 # reversed 114 | orbis.nodes$longitude[orbis.nodes$title == "Tenos"] <- 25.116 115 | 116 | # That's not the whole list so getting to 'done' will be a process. 117 | 118 | # the following code, when uncommented, will load from the API. But that only provides road and river connections 119 | #orbis.edges <- data.frame(source = vector(), target = vector(), type = vector(), cost = vector() ) 120 | #for (i in 1:length(orbis.nodes$id)) { 121 | # fromJSON(paste("http://orbis.stanford.edu/api/sites/",orbis.nodes$id[i], sep="")) -> X 122 | # Sys.sleep(.5) 123 | # orbis.edges <- rbind(orbis.edges,data.frame(source = rep(orbis.nodes$id[i],dim(X$routes)[1]), 124 | # target = X$routes[,2], 125 | # type = X$routes[,3], 126 | # cost = X$routes[,4])) 127 | # } 128 | 129 | # ... instead load from May, 2014 data 130 | orbis.edges <- read.csv(curl("https://stacks.stanford.edu/file/druid:mn425tz9757/orbis_edges_0514.csv")) 131 | 132 | use_data(orbis.nodes, overwrite = T) 133 | use_data(orbis.edges, overwrite = T) 134 | 135 | -------------------------------------------------------------------------------- /inst/scripts/collect.ramphs.R: -------------------------------------------------------------------------------- 1 | require(cawd) 2 | require(devtools) 3 | require(plyr) 4 | require(dplyr) # recommended to load plyr first 5 | require(jsonlite) 6 | require(sp) 7 | require(spatstat) 8 | 9 | #jamphs <- fromJSON("https://raw.githubusercontent.com/sfsheath/roman-amphitheaters/master/roman-amphitheaters.geojson") 10 | jamphs <- fromJSON("~/Documents/roman-amphitheaters/roman-amphitheaters.geojson") 11 | 12 | 13 | ramphs = data.frame(jamphs$features$id, 14 | jamphs$features$properties$title, 15 | jamphs$features$properties$label, 16 | jamphs$features$properties$buildingtype, 17 | jamphs$features$properties$certainty, 18 | jamphs$features$properties$private, 19 | jamphs$features$properties$capacity$quantity, 20 | jamphs$features$properties$moderncountry, 21 | jamphs$features$properties$chronogroup, 22 | jamphs$features$properties$created, 23 | jamphs$features$properties$lastuse$date, 24 | # sapply(jamphs$features$properties$wikipedia,"[",1), 25 | jamphs$features$properties$pleiades, 26 | jamphs$features$properties$dimensions$exteriormajor, 27 | jamphs$features$properties$dimensions$exteriorminor, 28 | jamphs$features$properties$dimensions$arenamajor, 29 | jamphs$features$properties$dimensions$arenaminor, 30 | is.na(jamphs$features$properties$exclude), # switch semantics to include == T rather than exclude 31 | stringsAsFactors = F 32 | ) 33 | names(ramphs) <- c("id","title","label","type","certainty","private", 34 | "capacity","mod.country","chrono.grp","created","last.use", 35 | "pleiades", 36 | "ext.major","ext.minor","arena.major","arena.minor", 37 | "include") 38 | 39 | ramphs$longitude <- sapply(jamphs$features$geometry$coordinates,"[",1) 40 | ramphs$latitude <- sapply(jamphs$features$geometry$coordinates,"[",2) 41 | ramphs$elevation <- sapply(jamphs$features$geometry$coordinates,"[",3) 42 | 43 | ramphs <- join(ramphs,plyr::count(ramphs,"type")) 44 | names(ramphs)[names(ramphs) == 'freq'] <- 'freq.type' 45 | ramphs$type <- ordered(reorder(ramphs$type,ramphs$freq.type)) 46 | 47 | ramphs <- join(ramphs,plyr::count(ramphs,"mod.country")) 48 | names(ramphs)[names(ramphs) == 'freq'] <- 'freq.mod.country' 49 | ramphs$mod.country <- ordered(reorder(ramphs$mod.country,ramphs$freq.mod.country)) 50 | 51 | ramphs <- join(ramphs,plyr::count(ramphs,"chrono.grp")) 52 | names(ramphs)[names(ramphs) == 'freq'] <- 'freq.chrono.grp' 53 | ramphs$chrono.grp <- ordered(reorder(ramphs$chrono.grp,ramphs$freq.chrono.grp)) 54 | ramphs$chrono.grp <- ordered(ramphs$chrono.grp,c("Republican", 55 | "Caesarean", 56 | "Augustan", 57 | "Julio-Claudian", 58 | "Neronian", 59 | "Vespasianic", 60 | "Flavian", 61 | "First Century", 62 | "Late1stEarly2nd", 63 | "Hadrianic", 64 | "Second Century", 65 | "Late Second Century", 66 | "Severan", 67 | "Post-Severan", 68 | "Fourth Century", 69 | "Imperial")) 70 | 71 | ramphs <- within(ramphs,elevation.quartile <- cut(elevation, quantile(elevation, probs=0:4/4), include.lowest=TRUE, labels=FALSE)) 72 | 73 | # calculate nearest vectors 74 | ramphs.distances <- spDists(as.matrix(ramphs[c("longitude","latitude")]),as.matrix(ramphs[c("longitude","latitude")]),longlat = TRUE) 75 | ramphs$nearest <- apply(ramphs.distances,2,sort)[2,] 76 | ramphs$nearest.second <- apply(ramphs.distances,2,sort)[3,] 77 | ramphs$nearest.third <- apply(ramphs.distances,2,sort)[4,] 78 | ramphs$nearest.fifth <- apply(ramphs.distances,2,sort)[6,] 79 | ramphs$nearest.tenth <- apply(ramphs.distances,2,sort)[11,] 80 | 81 | # calculate nearest in relation to Orbis sites 82 | ramphs.nearest.orbis <- spDists(as.matrix(filter(orbis.nodes,size.rank >=9)[c("longitude","latitude")]),as.matrix(ramphs[c("longitude","latitude")]),longlat = TRUE) 83 | ramphs$nearest.orbis9 <- apply(ramphs.nearest.orbis,2,sort)[1,] 84 | 85 | ramphs.distances.orbis <- spDists(as.matrix(filter(orbis.nodes,size.rank >=8)[c("longitude","latitude")]),as.matrix(ramphs[c("longitude","latitude")]),longlat = TRUE) 86 | ramphs$nearest.orbis8 <- apply(ramphs.distances.orbis,2,sort)[1,] 87 | 88 | #ramphs.distances.quarries <- spDists(as.matrix(oxrep.quarries[c("longitude","latitude")]),as.matrix(ramphs[c("longitude","latitude")]),longlat = TRUE) 89 | #ramphs$quarries.nearest <- apply(ramphs.distances.quarries,2,sort)[1,] 90 | 91 | # clustering 92 | ramphs$kmeans.cluster <- kmeans(dplyr::select(ramphs,latitude, longitude),10)$cluster 93 | ramphs$kmeans.cluster.neighbors <- kmeans(dplyr::select(ramphs,latitude, longitude, nearest),10)$cluster 94 | 95 | # impute capacities 96 | 97 | ramphs$imputed.capacity <- ifelse(is.na(ramphs$capacity),10000,ramphs$capacity) 98 | 99 | # temporary spatial.dataframe 100 | X.sp <- ramphs 101 | coordinates(X.sp) <- ~longitude + latitude 102 | proj4string(X.sp) <- CRS("+proj=longlat +datum=WGS84") 103 | 104 | # in a senatorial province? 105 | ramphs$prov.type <- ifelse(is.na(over(X.sp, awmc.senatorial.sp, fn = NULL)), ifelse(ramphs$mod.country =="Italy","italy","imperial"), "senatorial") 106 | 107 | # spatial 108 | ramphs.sp <- ramphs 109 | coordinates(ramphs.sp) <- ~longitude + latitude 110 | proj4string(ramphs.sp) <- CRS("+proj=longlat +datum=WGS84") 111 | 112 | 113 | 114 | longitudeExtent <- c(-9, 44) 115 | latitudeExtent <- c(31, 56) 116 | tmp.ppp <- as.ppp(dplyr::select(ramphs, longitude,latitude),owin(longitudeExtent,latitudeExtent)) 117 | 118 | #expand owin for analysis 119 | tmp.owin <- expand.owin(spatstat::convexhull(tmp.ppp), distance = .8) 120 | 121 | ramphs.ppp <- as.ppp(dplyr::select(ramphs, longitude,latitude, imputed.capacity),W = tmp.owin) 122 | 123 | use_data(ramphs, overwrite = T) 124 | use_data(ramphs.sp, overwrite = T) 125 | 126 | 127 | # cleanup 128 | rm(X.sp) 129 | 130 | # make periods 131 | ramphs.chrono.grps <- jamphs$`romanamphitheaterschronogroups` 132 | names(ramphs.chrono.grps) <- c("title", "earliest.start.date", "start.date", "end.date", "latest.end.date","comment") 133 | use_data(ramphs.chrono.grps, overwrite = T) 134 | -------------------------------------------------------------------------------- /man/awmc.persian.extent.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{awmc.persian.extent.sp} 5 | \alias{awmc.persian.extent.sp} 6 | \title{AWMC Map of Persian Empire.} 7 | \format{SP object} 8 | \source{ 9 | \url{http://awmc.unc.edu} 10 | } 11 | \usage{ 12 | awmc.persian.extent.sp 13 | } 14 | \description{ 15 | Available from the Ancient World Mapping Center under an CC-BY-NC License 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/awmc.roman.empire.117.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{awmc.roman.empire.117.sp} 5 | \alias{awmc.roman.empire.117.sp} 6 | \title{AWMC Map of Roman Empire in 117 AD.} 7 | \format{SP object} 8 | \source{ 9 | \url{http://awmc.unc.edu} 10 | } 11 | \usage{ 12 | awmc.roman.empire.117.sp 13 | } 14 | \description{ 15 | Available from the Ancient World Mapping Center under an CC-BY-NC License 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/awmc.roman.empire.200.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{awmc.roman.empire.200.sp} 5 | \alias{awmc.roman.empire.200.sp} 6 | \title{AWMC Map of Roman Empire in 200 AD.} 7 | \format{SP object} 8 | \source{ 9 | \url{http://awmc.unc.edu} 10 | } 11 | \usage{ 12 | awmc.roman.empire.200.sp 13 | } 14 | \description{ 15 | Available from the Ancient World Mapping Center under an CC-BY-NC License 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/awmc.roman.senatorial.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{awmc.roman.senatorial.sp} 5 | \alias{awmc.roman.senatorial.sp} 6 | \title{AWMC Map of Roman Senatorial Provinces.} 7 | \format{SP object} 8 | \source{ 9 | \url{http://awmc.unc.edu} 10 | } 11 | \usage{ 12 | awmc.roman.senatorial.sp 13 | } 14 | \description{ 15 | Available from the Ancient World Mapping Center under an CC-BY-NC License 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/awmc.roman.territory.60bc.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{awmc.roman.territory.60bc.sp} 5 | \alias{awmc.roman.territory.60bc.sp} 6 | \title{AWMC Map of Roman Territory in 60 BC.} 7 | \format{SP object} 8 | \source{ 9 | \url{http://awmc.unc.edu} 10 | } 11 | \usage{ 12 | awmc.roman.territory.60bc.sp 13 | } 14 | \description{ 15 | Available from the Ancient World Mapping Center under an CC-BY-NC License 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/awmc.senatorial.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{awmc.senatorial.sp} 5 | \alias{awmc.senatorial.sp} 6 | \title{AWMC Map of Senatorial Provinces of the Roman Empire} 7 | \format{SP object} 8 | \source{ 9 | \url{http://awmc.unc.edu} 10 | } 11 | \usage{ 12 | awmc.senatorial.sp 13 | } 14 | \description{ 15 | Available from the Ancient World Mapping Center under an CC-BY-NC License 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/darmc.rats.1to1500.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{darmc.rats.1to1500.sp} 5 | \alias{darmc.rats.1to1500.sp} 6 | \title{DARMC Rat Remains} 7 | \format{SP object} 8 | \source{ 9 | \url{http://darmc.harvard.edu/icb/icb.do?keyword=k40248&pageid=icb.page601659} 10 | } 11 | \usage{ 12 | darmc.rats.1to1500.sp 13 | } 14 | \description{ 15 | Digital Atlas of Roman and Medieval Civilization data on archaeologically record rat remains. Available under a CC-BY-NC-SA license. See source for details. 16 | } 17 | \details{ 18 | The file has a few 0,0 lat/long pairs so it is probably best to remove those before plotting. 19 | } 20 | \keyword{datasets} 21 | 22 | -------------------------------------------------------------------------------- /man/darmc.shipwrecks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{darmc.shipwrecks} 5 | \alias{darmc.shipwrecks} 6 | \title{DARMC Shipwrekcs} 7 | \format{data.frame} 8 | \source{ 9 | \url{http://darmc.harvard.edu/icb/icb.do?keyword=k40248&pageid=icb.page601659} 10 | } 11 | \usage{ 12 | darmc.shipwrecks 13 | } 14 | \description{ 15 | Digital Atlas of Roman and Medieval Civilization data on shipwrecks. Available under a CC-BY-NC-SA license. See source for details. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/darmc.shipwrecks.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{darmc.shipwrecks.sp} 5 | \alias{darmc.shipwrecks.sp} 6 | \title{DARMC Shipwrekcs (SP)} 7 | \format{SP Object} 8 | \source{ 9 | \url{http://darmc.harvard.edu/icb/icb.do?keyword=k40248&pageid=icb.page601659} 10 | } 11 | \usage{ 12 | darmc.shipwrecks.sp 13 | } 14 | \description{ 15 | Digital Atlas of Roman and Medieval Civilization data on shipwrecks as an sp object. Available under a CC-BY-NC-SA license. See source for details. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/nomisma.greek.mints.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{nomisma.greek.mints} 5 | \alias{nomisma.greek.mints} 6 | \title{Nomisma.org: Greek Mints} 7 | \format{A data frame (needs info on columns)} 8 | \source{ 9 | \url{http://nomisma.org/} 10 | } 11 | \usage{ 12 | nomisma.greek.mints 13 | } 14 | \description{ 15 | Data available under a CC-By license. All mints said by Nomisma to be "part of" Greek numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient cultural affinity. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/nomisma.greek.mints.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{nomisma.greek.mints.sp} 5 | \alias{nomisma.greek.mints.sp} 6 | \title{Nomisma.org: Greek Mints (sp)} 7 | \format{SP Object (needs info on columns)} 8 | \source{ 9 | \url{http://nomisma.org/} 10 | } 11 | \usage{ 12 | nomisma.greek.mints.sp 13 | } 14 | \description{ 15 | Data available under a CC-By license. All mints said by Nomisma to be "part of" Greek numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient cultural affinity. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/nomisma.roman.mints.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{nomisma.roman.mints} 5 | \alias{nomisma.roman.mints} 6 | \title{Nomisma.org: Roman Mints} 7 | \format{A data frame (needs info on columns)} 8 | \source{ 9 | \url{http://nomisma.org/} 10 | } 11 | \usage{ 12 | nomisma.roman.mints 13 | } 14 | \description{ 15 | Data available under a CC-By license. All mints said by Nomisma to be "part of" Roman numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient poltical circumstances. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/nomisma.roman.mints.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{nomisma.roman.mints.sp} 5 | \alias{nomisma.roman.mints.sp} 6 | \title{Nomisma.org: Roman Mints (sp)} 7 | \format{SP Object (needs info on columns)} 8 | \source{ 9 | \url{http://nomisma.org/} 10 | } 11 | \usage{ 12 | nomisma.roman.mints.sp 13 | } 14 | \description{ 15 | Data available under a CC-By license. All mints said by Nomisma to be "part of" Roman numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient political circumstances. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/nomisma.roman.provincial.mints.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{nomisma.roman.provincial.mints} 5 | \alias{nomisma.roman.provincial.mints} 6 | \title{Nomisma.org: Roman Provincial Mints (Incomplete)} 7 | \format{A data frame (needs info on columns)} 8 | \source{ 9 | \url{http://nomisma.org/} 10 | } 11 | \usage{ 12 | nomisma.roman.provincial.mints 13 | } 14 | \description{ 15 | Data available under a CC-By license. All mints said by Nomisma to be "part of" Roman numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient politcal circumstances. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/nomisma.roman.provincial.mints.sp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{nomisma.roman.provincial.mints.sp} 5 | \alias{nomisma.roman.provincial.mints.sp} 6 | \title{Nomisma.org: Roman Provincial Mints (sp) (Incomplete)} 7 | \format{SP Object (needs info on columns)} 8 | \source{ 9 | \url{http://nomisma.org/} 10 | } 11 | \usage{ 12 | nomisma.roman.provincial.mints.sp 13 | } 14 | \description{ 15 | Data available under a CC-By license. All mints said by Nomisma to be "part of" Roman numismatics are included. Meaning this is a modern term indicating disciplinary practice, not a description of ancient political circumstances. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/orbis.edges.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{orbis.edges} 5 | \alias{orbis.edges} 6 | \title{Stanford Orbis Model of Roman Connectivity: Edges} 7 | \format{A data frame (needs info on columns)} 8 | \source{ 9 | \url{http://purl.stanford.edu/mn425tz9757} 10 | } 11 | \usage{ 12 | orbis.edges 13 | } 14 | \description{ 15 | Data available under a CC-By license. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/orbis.nodes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{orbis.nodes} 5 | \alias{orbis.nodes} 6 | \title{Stanford Orbis Model of Roman Connectivity: Nodes} 7 | \format{A data frame (needs info on columns)} 8 | \source{ 9 | \url{http://orbis.stanford.edu/api} 10 | } 11 | \usage{ 12 | orbis.nodes 13 | } 14 | \description{ 15 | The API is public but does not give an explicit license. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/ramphs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{ramphs} 5 | \alias{ramphs} 6 | \title{Roman Amphitheaters.} 7 | \format{A data frame (needs info on columns)} 8 | \source{ 9 | \url{http://github.com/sfsheath/roman-amphitheaters} 10 | } 11 | \usage{ 12 | ramphs 13 | } 14 | \description{ 15 | Data for Roman amphitheaters. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/ramphs.chrono.grps.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{ramphs.chrono.grps} 5 | \alias{ramphs.chrono.grps} 6 | \title{Roman Amphitheaters: Chronological Groups.} 7 | \format{A data frame (needs info on columns)} 8 | \source{ 9 | \url{http://github.com/sfsheath/roman-amphitheaters} 10 | } 11 | \usage{ 12 | ramphs.chrono.grps 13 | } 14 | \description{ 15 | Provides start dates and end dates for the chronological groups in the chrono.grp column of the ramphs object. merge() can be used to combine the two objects. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/weighted.deciles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/weighted.deciles.R 3 | \name{weighted.deciles} 4 | \alias{weighted.deciles} 5 | \title{Weighted Deciles} 6 | \usage{ 7 | weighted.deciles(Qv, Wv, decile.title, decile.xlab, decile.ylab, scale.name) 8 | } 9 | \description{ 10 | Weighted Cumulative Cumulative Sum of 11 | } 12 | 13 | --------------------------------------------------------------------------------