Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
man
DESCRIPTION
LICENSE
NAMESPACE
README.md
_config.yml

README.md

OIEparser

an R package to create SQLite database from the OIE reports

Installation from github:

library(devtools)

install_github('solymosin/OIEparser')

Example

library(OIEparser)

options(stringsAsFactors=F)

downloading the data of 2018

OIEparser(ystart=2018, yend=2018, timeout=10000, dbfile='db2018.sqlite')

query the ASF outbreaks in wild boars, between 01/01/2018 and 01/03/2018

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)

png

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')

png

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')

png

Export as ESRI Shape file

st_write(sftab, 'ASF.shp')
Writing layer `ASF' to data source `ASF.shp' using driver `ESRI Shapefile'
features:       8812
fields:         10
geometry type:  Point

Opening in QGIS

QGIS

Export as KML

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)

Opening in Google Earth

Google Earth

You can’t perform that action at this time.