an R package to create SQLite database from the OIE reports
library(devtools)
install_github('solymosin/OIEparser')
library(OIEparser)
options(stringsAsFactors=F)
OIEparser(ystart=2018, yend=2018, timeout=10000, dbfile='db2018.sqlite')
db = dbConnect(RSQLite::SQLite(), 'db2018.sqlite')
sql = "SELECT * FROM outbreaks LEFT JOIN header ON outbreaks.rptid = header.rptid where
disease='African swine fever' and
sdate>'2018-01-01' and
sdate<'2018-03-01' and
species like '%wild%'"
tab = dbGetQuery(db, sql)
head(tab)
specieslatlonsdateedaterptidagentdiseaseurlrptid..10
Wild boar:Suidae(Sus scrofa) 52.433889 20.795833 2018-01-02 2018-01-08 2 African swine fever virus African swine fever http://www.oie.int/wahis_2/temp/reports/en_fup_0000025830_20180202_170404.pdf2
Wild boar:Suidae(Sus scrofa) 52.024444 21.168333 2018-01-02 2018-01-08 2 African swine fever virus African swine fever http://www.oie.int/wahis_2/temp/reports/en_fup_0000025830_20180202_170404.pdf2
Wild boar:Suidae(Sus scrofa) 52.024444 21.167221 2018-01-02 2018-01-06 2 African swine fever virus African swine fever http://www.oie.int/wahis_2/temp/reports/en_fup_0000025830_20180202_170404.pdf2
Wild boar:Suidae(Sus scrofa) 52.051944 21.186944 2018-01-02 2018-01-06 2 African swine fever virus African swine fever http://www.oie.int/wahis_2/temp/reports/en_fup_0000025830_20180202_170404.pdf2
Wild boar:Suidae(Sus scrofa) 52.061667 21.180833 2018-01-02 2018-01-06 2 African swine fever virus African swine fever http://www.oie.int/wahis_2/temp/reports/en_fup_0000025830_20180202_170404.pdf2
Wild boar:Suidae(Sus scrofa) 52.434167 20.916389 2018-01-02 2018-01-09 2 African swine fever virus African swine fever http://www.oie.int/wahis_2/temp/reports/en_fup_0000025830_20180202_170404.pdf2
library(sp)
library(sf)
pts = cbind(x=as.numeric(tab$lon), y=as.numeric(tab$lat))
sptab = SpatialPointsDataFrame(pts, tab, proj4string=CRS('+init=epsg:4326'))
sftab = as(sptab, 'sf')
library(tmap)
tm_shape(sftab) + tm_dots(col='red', size=0.1)
data(World)
wrld = st_transform(World, 4326)
tm_shape(wrld) + tm_polygons() +
tm_shape(sftab) + tm_dots(col='yellow', size=0.1) +
tm_style('grey')
tm_shape(wrld, bbox=st_bbox(sftab)) + tm_polygons() +
tm_shape(sftab) + tm_dots(col='yellow', size=0.1) +
tm_compass(color.light='grey90', size=2, fontsize=1, type='rose', position=c('left', 'top')) +
tm_scale_bar(size=0.6, position=c('right', 'top'))+
tm_style('grey')
st_write(sftab, 'ASF.shp')
Writing layer `ASF' to data source `ASF.shp' using driver `ESRI Shapefile'
features: 8812
fields: 10
geometry type: Point
library(plotKML)
pnt = 'http://plotkml.r-forge.r-project.org/circle.png'
kml(sptab, folder.name='ASF', file.name='ASF.kml',
subfolder.name='outbreaks', shape=pnt, size=1,
kmz=T, colour='red',
TimeSpan.begin=sptab$sdate, TimeSpan.end=sptab$edate,
points_names=paste(sptab$sdate, sptab$edate, sep=' - '),
html.table=sptab$url)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.