https://github.com/abarbour/yhs.catalog
The Yang, Hauksson, and Shearer (2012) focal mechanism catalog for southern California in R
https://github.com/abarbour/yhs.catalog
california dataset earthquakes r
Last synced: 4 months ago
JSON representation
The Yang, Hauksson, and Shearer (2012) focal mechanism catalog for southern California in R
- Host: GitHub
- URL: https://github.com/abarbour/yhs.catalog
- Owner: abarbour
- Created: 2015-03-23T23:06:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-03-28T18:22:28.000Z (over 3 years ago)
- Last Synced: 2023-03-22T07:11:20.706Z (over 2 years ago)
- Topics: california, dataset, earthquakes, r
- Language: R
- Homepage: https://zenodo.org/record/807720
- Size: 164 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yhs.catalog [](https://travis-ci.org/abarbour/yhs.catalog) [](http://www.gnu.org/licenses/gpl-3.0.html) [](https://zenodo.org/badge/latestdoi/1277/abarbour/yhs.catalog)
This is an R package which bundles
the Yang, Hauksson, and Shearer (2012) [relocated focal mechanism catalog][yhs]
together.
A note on the version number: the patch version represents the year and month the dataset
was last updated (e.g. 20150301 would be 01-March-2015).
## Example ##
Install the package:
if (!require(devtools)) install.packages("devtools")
devtools::install_github("abarbour/yhs.catalog")
Load the package (lazy loading is enabled, so datasets are
attached by default):
library(yhs.catalog)
Inspect the data:
class(yhs)
str(yhs)
Tabulate classifications:
with(yhs,{
Tsr <- table(Source, Quality)
Tyr <- table(Year, Quality)
})
plot(Tsr)
plot(Tyr)
Plot in spatial coordinates by year:
library(viridis)
library(raster)
calif <- ggplot2::map_data("state", region = 'california')
r <- raster(xmn=-123, xmx=-114, ymn=31, ymx=37, resolution=0.1)
coordinates(r) %>% as_data_frame %>% dplyr::rename(Lon=x, Lat=y) -> crds
re <- extent(r)
year_raster <- function(DatY){
DatY %>% dplyr::select(Lon.deg, Lat.deg) -> dmat
as.data.frame(rasterize(dmat, r, fun='count')) %>%
dplyr::rename(Count = layer) %>%
dplyr::mutate(Density = Count / max(Count, na.rm=TRUE), logCount = log10(Count)) -> .ry.
cbind(crds, .ry.)
}
yhs %>% dplyr::group_by(Year) %>% dplyr::do(year_raster(.)) -> Allyears
p <- ggplot(Allyears, aes(x=Lon, y=Lat)) +
geom_raster(aes(fill = logCount)) +
coord_quickmap() +
facet_wrap(~Year)+
scale_fill_viridis(option="plasma", direction=-1, na.value="grey90")+
geom_path(data=calif, aes(x=long, y=lat, group = group), colour="lightgrey")+
geom_path(data=saltonsea, aes(x=Lon.deg, y=Lat.deg), colour="lightgrey")+
theme_minimal() +
theme(axis.text = element_text(size=6),
axis.title = element_text(size=10, hjust=0),
plot.title = element_text(size=12,face="bold"),
legend.position=c(0.83,-0.07),
legend.direction="horizontal") +
xlim(re[1], re[2])+
ylim(re[3], re[4])+
xlab("Longitude") +
ylab("Latitude") +
ggtitle("Earthquake Densities in Southern California")
![alt text][years]
[yhs]: http://scedc.caltech.edu/research-tools/alt-2011-yang-hauksson-shearer.html
[years]: NOBUILD/readme/years.png "Earthquakes by year"