Generate GeoJSON townlands from OpenStreetMap data

Based on an enquiry from a visitor to the OSM Ireland website I had a little play with the OSM data for Ireland to see if I could offer advice on how to generate shape files of townland areas. Below is the process I used and it can be adapted for other administrative boundaries such as electoral boundaries or baronies.

Make sure you have the required software installed. On Mac I used:

brew install osmium-tool osmosis osmconvert jq josm

Download the OSM data for Ireland. Available from GeoFabrik here. Or directly with wget:

wget https://download.geofabrik.de/europe/ireland-and-northern-ireland-latest.osm.pbf

Then pull out the areas based on how the areas are tagged:

osmium tags-filter data/ireland-and-northern-ireland-latest.osm.pbf \
  boundary=administrative admin_level=10 locality=townland \
  -o data/townlands.osm.pbf --overwrite

Convert to GeoJSON:

osmium export data/townlands.osm.pbf -o data/townlands.geojson --geometry-type=polygon --output-format=geojson

We can have a check of the output to count the number of townlands with:

jq '.features | length' data/townlands.geojson

I got 66386 townlands for Ireland.

I could then open the GeoJSON file in JOSM or qGIS for viewing. Although the file is large so I had to run JOSM with 8GB memory rather than the default 4GB.

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>