Accessing CEH Gridded Estimates of Areal Rainfall (GEAR) with Python

The Centre for Ecology & Hydrology (CEH) produce a dataset which provides an estimate of daily rainfall on a 1km grid for Great Britain and Northern Ireland from all the way back to 1890 onward to 2014.

The data is hosted in NetCDF format hosted on an OPeNDAP server. At the ...

Continue reading »

Speedup Fiona with LRU caching

At some point you're going to care about how long it takes your geoprocessing algorithm to run. While the Fiona and Shapely libraries make efforts to be as efficient as possible, a lot will depend on the algorithms you use them in.

I've written before about how spatial ...

Continue reading »

Homebrew Oxontime RTI display with Raspberry Pi

Update: As of 2016-03-31 the Oxontime service has changed provider and the API is no longer functional. Presumably a new API will be made available at some point. This post remains for posterity.

The Oxontime Real Time Information (RTI) system provides real time predictions for bus departures in Oxfordshire, which ...

Continue reading »

Find ArcMap document version with Python

This post shows how to find the version number of an ArcGIS map document (.mxd) programmatically using Python. It seems that arcpy does not provide a method to do this itself.

ArcGIS map documents are actually Microsoft OLE2 files (also called Structured Storage, Compound File Binary Format or Compound Document ...

Continue reading »

Masking Rasterio Layers with Vector Features

This post shows how to extract data from a raster only where it intersects a vector feature using Rasterio. Fiona is used to read the vector data, and Shapely is used only as a convenience to calculate the feature's bounding box.

GDAL provides a function to "burn" vector shapes ...

Continue reading »

Embedding a Leaflet map in a Qt application

Embedding a map in a Qt application using Leaflet is surprisingly easy. The QtWebKit.QWebView object can be used to create a browser window within a Qt dialog. Within this browser window you can create an interactive map using Leaflet just as you would for any other browser. Communication between ...

Continue reading »

Converting British National Grid and Irish Grid References: A Practical Example

The Environment Agency recently released their database of River Habitat Surveys (RHS) as open data, available from the GeoStore under the Open Government Licence. RHS is described as the 'standard for collecting data on the physical character and quality of river habitats across the UK'. The data comes in the ...

Continue reading »

Validating user input in PyQt4 using QValidator

This post demonstrates how to use the QValidator class to validate text input in PyQt4. Text validation can help the user to understand what information is required when entering data into a form. For example, preventing a user from entering letters into a text field that expects a number makes ...

Continue reading »

Reduce the file size of PDFs with Ghostscript

Portable Document Format (PDF) is a common format used for publishing maps. PDFs can contain both raster and vector data and can be read by a large number of freely available viewer applications, such as Adobe Reader and Okular.

Adobe Reader Pro can be used to optimize the size of ...

Continue reading »

Merging vector layers with ogr2ogr

In the example below we will merge a group of SQLite layers (first.sqlite, second.sqlite, third.sqlite, ...) into a single SQLite layer (topographicarea.sqlite).

The first step is to create an empty layer with the correct schema (i.e., the same geometry type and fields).

ogr2ogr -f SQLite -nln ...

Continue reading »