Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # For illustrative purpose plot the points on a map
- # Load suitable library and plot the area of interest.
- library(rworldmap)
- newmap <- getMap(resolution = "high")
- # Plot refined to Africa
- plot(newmap,
- xlim = c(-25,60),
- ylim = c(-35, 37),
- asp = 1)
- # A more accurate plot can be get by using the extreme points of the continent
- library(ggmap)
- africa.limits <- geocode(c("Iles des Chiens, Tunisia",
- "Cape Agulhas, South Africa",
- "Santa Antão, Cape Verde Islands",
- "Rodrigues, Mauritius")
- )
- africa.limits
- plot(newmap,
- xlim = range(africa.limits$lon),
- ylim = range(africa.limits$lat),
- asp = 1
- )
- # Import the customised ACLED dataset
- acled<-read.csv("/home/R/acled_1997-2011.csv", header=TRUE)
- head(acled)
- # Plot the points on the map
- points(acled$lon,acled$lat,col="red",cex=0.3)
- # Load shapefile with the 1x1 degree grid
- library("sp")
- library("rgdal")
- # Set the correct working directory
- setwd("/home/R/Shapefiles")
- # Check layers
- ogrListLayers("ne_10m_graticules_1.shp")
- # Load the shapefile
- shape<-readOGR(dsn="/home/R/Shapefiles",layer="ne_10m_graticules_1")
- plot(shape,add=TRUE)
- # TODO: Aggregate points-to-grid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement