Gis

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.

Spatial microsimulation 101

I recently gave a presentation for analysts and data modellers at the Department for Work and Pensions (DWP) introducing the spatial microsimulation technique (specifically the IPF flavour), and below are the slides I used (use spacebar to navigate through the slides): Alternatively you can download the presentation as a standard html file to open in your browser. Much of the content is based on material from Spatial Microsimulation with R by Robin Lovelace and Morgane Dumont (online content | physical book) and my own rakeR package for R.

Simplify polygons without creating slivers

When you download geographical data the polygons are often highly detailed, leading to large file sizes and slow processing times. Often this detail is unnecessary if you’re not intending to produce small–scale maps. Most thematic maps, for example, tend to compare large geographies such as nations or regions, so the detail is unnecessary. Likewise, if you’re producing your map for use on the web, for example as an interactive visualisation, too much detail can slow the rendering and responsiveness of your app.

House prices 3d visualisation

On Saturday (24th September) I participated in the UK Data Service’s Open Data Dive Hackathon. The goal was to use open data to create an artefact or visualisation with the grand prize being the opportunity to have your artefact printed on one of MMU’s industrial 3D printers. I wanted to explore using a QGIS plugin called qgis2threejs to create 3D visualisations using the three.js javascript framework that allows you to render your visualisation in a WebGL-capable browser.

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.

Creating a globe in QGIS

I love a good bit of map making and I have a bit of time on my hands at the moment, so I followed this tutorial by Steven Bernard to create a globe from a world map in QGIS: The steps are straightforward. The fiddly bit was getting the line endings and indentation correct which are essential in Python, so I copied the text out and created a gist with line endings preserved:

Downloading ONS geography lookups

I wasn’t able to easily download ONS output area lookups from either their main site or the geoportal. I kept getting errors that the download failed. I suspect on Linux the URLs are considered malformed; they might work on Windows. Anyway, on Linux use links from the geoportal. They directly link to the .zip files (and the main site links to the geoportal, anyway). I used cURL on the command line and escaped the brackets in the URL with :

Dissolve polygons in R

Dissolving polygons is another fairly elementary GIS task that I need to perform regularly. With R this is can be a bit involved, but once done is fully reproducible and the code can be re-used. This post is essentially a companion piece to Clipping polygons in R; I wrote both because I often forget how to complete these tasks in R. Getting started Let’s gather together everything we need to complete this example.

Clipping polygons in R

Clipping polygons is a basic GIS task. It involves removing unneeded polygons outside of an area of interest. For example, you might want to study all local authorities (LADs) in the Yorkshire and the Humber region but can only obtain shapefiles that contain all the LADs in the UK. Removing the LADs outside of Yorkshire and the Humber could be achieved by ‘clipping’ the shapefile of LADs, using the extent of the larger region as a template.

Why do internet maps use Mercator?

I’ve often wondered why Google, as well as other internet map providers, use the Mercator projection. It was originally designed for nautical navigation by keeping lines of latitude perpendicular to lines of longitude. The cost was that land areas were distorted, and the distortion increases nearer the poles, making countries in very low or very high latitudes look bigger than they really are. Using the Mercator projection, Greenland looks bigger than Australia for example, but in fact Australia is about three times the area of Greenland.