Spatial packages and Travis

A number of R spatial libraries have been updated in the last couple of weeks, and this has played havoc with my Travis–CI build. I had still been using Ubuntu Trusty with Travis which uses old versions of libraries like rgdal and rgeos, so I needed to move to updated versions of these. In addition sf has now become a dependency for a number of spatial packages like tmap, and this uses libudunits2-dev which isn't installed by default. [Read More]
sf  travis  rstats  gis 

townsendr interactive map

This week I updated my Townsend Material Deprivation Score project. The update makes townsendr an interactive online map of deprivation that users can simply view in their browser, rather than having to download and run the R code or view only static maps. I think the result is much more intuitive and useful. Making the map interactive is achieved by using Shiny, a technology for R to make interactive charts and plots. [Read More]

Dissolve polygons in R

Dissolving polygons is an elementary GIS task that I need to perform regularly. A dissolve removes internal boundaries, leaving only the outline. Packages Install and load the packages we’ll need. I use sf because it’s more intuitive than rgdal, and I’m loading tidyverse because it plays well with sf. # install.packages(c("tidyverse", "sf")) library("tidyverse") library("sf") Boundary data Download the shapefile we’re going to dissolve. tmp_dir = tempdir() tmp = tempfile(tmpdir = tmp_dir, fileext = ". [Read More]

Clip polygons in R

Clipping polygons is a common GIS task. For example, you might want to study local authorities (LADs) in the Yorkshire and the Humber region but can only obtain a shapefile with all the LADs in England. Removing all the LADs outside of the Yorkshire and the Humber can be achieved by ‘clipping’ the LADs, using the extent of the larger region as a template.

[Read More]
R  rstats  GIS  sf  clip  polygon-clip 

GIS shapefile resources

UK UK shapefiles for various administrative geographies can be easily obtained from UK Data Service Census Support boundary data pages, and most use the permissive Open Government License. Countries DIVA-GIS is a pretty good source for country shapefiles, including administrative boundaries, natural features, and infrastructure. Thanks to Tom B for pointing this one out. Geofabrik provide OpenStreetMap data extracts in a convenient format. Country-specific coordinate reference systems (projections) When viewing a map of the world it's common to use the WGS84 (World Geodetic System 1984) coordinate reference system (CRS), although others can be used. [Read More]

Installing RGDAL and RGEOS in R on Linux

RGDAL The RGDAL package is used by R and RStudio to plot maps. Under Linux you may encounter one or two errors when trying to install the package: Error: gdal-config not found. The gdal-config script distributed with GDAL could not be found. Or: configure: error: proj_api.h not found in standard or given locations. ERROR: configuration failed for package 'rgdal' You experience these errors because R in Linux installs the packages from source (rather than a ready-compiled binary) and you need additional libraries to compile RGDAL. [Read More]
rstats  gis  rgdal  rgeos