Importing shapefiles


options(width=100)

The data used here are available from Upsala Conflict Data Program.


# To download the data, use the *R*-code
#
# download.file("https://ucdp.uu.se/downloads/ged/ucdp-ged-poly-v-1-1-shape.zip",
#               "ucdp-ged-poly-v-1-1-shape.zip")

unzip("ucdp-ged-poly-v-1-1-shape.zip",list=TRUE)
   Name                                                     Length  Date
1  ARCGIS Readme.txt                                            251 2012-03-28 16:07:00
2  UCDP GED Conflict Polygons Codebook version 1.1-2011.pdf 1006764 2012-03-28 16:02:00
3  UCDPGEDpoly.dbf                                           744174 2012-03-21 16:09:00
4  UCDPGEDpoly.prj                                              145 2012-03-21 16:09:00
5  UCDPGEDpoly.sbn                                             4820 2012-03-21 16:09:00
6  UCDPGEDpoly.sbx                                              372 2012-03-21 16:09:00
7  UCDPGEDpoly.shp                                            73892 2012-03-21 16:09:00
8  UCDPGEDpoly.shx                                             4100 2012-03-21 16:09:00
9  UCDPGEDpolyyear.dbf                                      1907966 2012-03-21 16:08:00
10 UCDPGEDpolyyear.prj                                          145 2012-03-21 16:08:00
11 UCDPGEDpolyyear.sbn                                        11620 2012-03-21 16:08:00
12 UCDPGEDpolyyear.sbx                                          764 2012-03-21 16:08:00
13 UCDPGEDpolyyear.shp                                       165460 2012-03-21 16:08:00
14 UCDPGEDpolyyear.shx                                         9156 2012-03-21 16:08:00

unzip("ucdp-ged-poly-v-1-1-shape.zip",
      files=c(
          "UCDPGEDpoly.shx",
          "UCDPGEDpoly.shp",
          "UCDPGEDpoly.dbf"
          ))

The following makes use of the sf package. You may need to install it from CRAN using the code install.packages("sf") if you want to run this on your computer. (The package is already installed on the notebook container, however.)


library(sf)
# All three of the following lines are equivalent:
UCDPGEDpoly <- st_read("UCDPGEDpoly.shx")
Linking to GEOS 3.7.1, GDAL 2.4.0, PROJ 5.2.0

Reading layer `UCDPGEDpoly' from data source `/home/elff/webdevel/sphinx/elff.eu/publications/data-management-r/spatial-geographical-data/UCDPGEDpoly.shx' using driver `ESRI Shapefile'
Simple feature collection with 500 features and 20 fields
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: -17.3381 ymin: -34.1831 xmax: 50.8833 ymax: 37.0542
CRS:            NA

UCDPGEDpoly <- st_read("UCDPGEDpoly.shp")
Reading layer `UCDPGEDpoly' from data source `/home/elff/webdevel/sphinx/elff.eu/publications/data-management-r/spatial-geographical-data/UCDPGEDpoly.shp' using driver `ESRI Shapefile'
Simple feature collection with 500 features and 20 fields
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: -17.3381 ymin: -34.1831 xmax: 50.8833 ymax: 37.0542
CRS:            NA

UCDPGEDpoly <- st_read("UCDPGEDpoly.dbf")
Reading layer `UCDPGEDpoly' from data source `/home/elff/webdevel/sphinx/elff.eu/publications/data-management-r/spatial-geographical-data/UCDPGEDpoly.dbf' using driver `ESRI Shapefile'
Simple feature collection with 500 features and 20 fields
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: -17.3381 ymin: -34.1831 xmax: 50.8833 ymax: 37.0542
CRS:            NA

str(UCDPGEDpoly)
Classes ‘sf’ and 'data.frame':  500 obs. of  21 variables:
 $ pName     : chr  "LNE-1-17-A" "LNE-1-189A-A" "LNE-1-19-A" "LNE-1-191-A" ...
 $ lat       : num  4.32 -4.31 12.72 -5.63 15.5 ...
 $ lon       : num  18.6 15.3 20.5 12.5 22.9 ...
 $ type_of_vi: num  1 1 1 1 1 1 1 1 1 1 ...
 $ dyadID_1  : num  17 0 19 191 20 210 23 0 0 811 ...
 $ Split_dyad: num  0 1 0 0 0 0 0 1 1 0 ...
 $ dyad_name : chr  "Government of Central African Republic - Military faction (Forces of André Kolingba)" "Government of the Republic of Congo - Cobras" "Government of Chad - MOSANAT" "Government of Angola - FLEC-R" ...
 $ conflict_n: chr  "Central African Republic" "Congo" "Chad" "Angola (Cabinda)" ...
 $ conflict_I: num  222 214 91 192 91 141 91 191 177 268 ...
 $ side_A    : chr  "Government of Central African Republic" "Government of the Republic of Congo" "Government of Chad" "Government of Angola" ...
 $ side_A_ID : num  482 484 483 540 483 520 483 615 432 530 ...
 $ side_B    : chr  "Military faction (Forces of André Kolingba)" "Cobras" "MOSANAT" "FLEC-R" ...
 $ side_B_ID : num  1406 1398 1290 1392 1288 ...
 $ no_of_even: num  11 23 2 2 3 11 3 2 2 2 ...
 $ low_est   : num  231 1396 50 0 0 ...
 $ best_est  : num  231 1396 50 0 0 ...
 $ high_est  : num  331 3456 50 72 930 ...
 $ date_first: Date, format: "2001-05-27" "1997-06-05" "1989-03-03" ...
 $ date_fir_1: Date, format: "2001-06-01" "1997-06-06" "1989-03-03" ...
 $ date_last : Date, format: "2001-12-01" "1997-10-16" "1989-03-03" ...
 $ geometry  :sfc_POLYGON of length 500; first list element: List of 1
  ..$ : num [1:5, 1:2] 18.6 18.6 18.6 18.6 18.6 ...
  ..- attr(*, "class")= chr [1:3] "XY" "POLYGON" "sfg"
 - attr(*, "sf_column")= chr "geometry"
 - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
  ..- attr(*, "names")= chr [1:20] "pName" "lat" "lon" "type_of_vi" ...

print(UCDPGEDpoly[c(7,18,20)])
Simple feature collection with 500 features and 3 fields
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: -17.3381 ymin: -34.1831 xmax: 50.8833 ymax: 37.0542
CRS:            NA
First 10 features:
                                                                              dyad_name date_first
1  Government of Central African Republic - Military faction (Forces of André Kolingba) 2001-05-27
2                                          Government of the Republic of Congo - Cobras 1997-06-05
3                                                          Government of Chad - MOSANAT 1989-03-03
4                                                         Government of Angola - FLEC-R 1994-02-07
5                                                   Government of Chad - Islamic Legion 1990-04-03
6                                                           Government of Somalia - USC 1990-11-18
7                                                              Government of Chad - MPS 1990-11-14
8                                             Government of Algeria - Takfir wa'l Hijra 1991-11-29
9                                                            Government of Mali - ATNMC 2008-05-06
10                                                        Government of Ethiopia - IGLF 1991-10-10
    date_last                       geometry
1  2001-12-01 POLYGON ((18.5833 4.31667, ...
2  1997-10-16 POLYGON ((15.315 -4.37972, ...
3  1989-03-03 POLYGON ((20.9052 9.88969, ...
4  1994-11-15 POLYGON ((12.5167 -5.63333,...
5  1990-11-16 POLYGON ((22.7833 14.9667, ...
6  1991-01-28 POLYGON ((45.3667 2.01667, ...
7  1990-11-25 POLYGON ((22.7833 14.9667, ...
8  1991-12-09 POLYGON ((6.88333 33.2833, ...
9  2008-12-20 POLYGON ((-6.0197 14.6437, ...
10 1991-10-10 POLYGON ((42.1258 9.25944, ...

Downloadable R script and interactive version

Explanation

The link with the “jupyterhub” icon directs you to an interactive Jupyter1 notebook, which runs inside a Docker container2. There are two variants of the interative notebook. One shuts down after 60 seconds and does not require a sign it. The other requires sign in using your ORCID3 credentials, yet shuts down only after 24 hours. (There is no guarantee that such a container persists that long, it may be shut down earlier for maintenance purposes.) After shutdown all data within the container will be reset, i.e. all files created by the user will be deleted.4

Above you see a rendered version of the Jupyter notebook.5

1

For more information about Jupyter see http://jupyter.org. The Jupyter notebooks make use of the IRKernel package.

2

For more information about Docker see https://docs.docker.com/. The container images were created with repo2docker, while containers are run with docker spawner.

3

ORCID is a free service for the authentication of researchers. It also allows to showcase publications and contributions to the academic community such as peer review.. See https://info.orcid.org/what-is-orcid/ for more information.

4

The Jupyter notebooks come with NO WARRANTY whatsoever. They are provided for educational and illustrative purposes only. Do not use them for production work.

5

The notebook is rendered with the help of the nbsphinx extension.