With a number of Irish data sets having been made available under the Creative Commons Attribution 4.0 license I thought it would be interesting to take a look at one of these, the Sites and Monuments Record (SMR) from the National Monuments Service. This falls under the Archaeological Survey of Ireland which is a unit of the National Monuments Service. It basically records any known monuments from mainly pre-dating AD 1700 and some from the post-AD 1700 period.
I very briefly queried this database online using the ESRI web-app which limits the number of visible records to less than 1000. The next step I did was to download each county’s shapefile individually (as the entire country cannot be downloaded together). Once these were downloaded as 27 different shapefiles the next task was to merge them into one. The easiest way to merged these was to use the Geospatial Data Abstraction Library (GDAL). The easiest and most convenient way to install this is to use the OSGeo4w installer that takes the hard work out of it. It is available from here. Once this is downloaded and installed (I chose the express install and only installed GDAL.
I had the 27 shapefiles in a folder on my desktop called ‘National Monuments’. I opened the OSGeo4w shell and changed the directory to the National Monuments folder and made a new directory within called ‘merged’. The following script was then run:
C:\>cd C:\Users\Donie\Desktop\National_Monuments C:\Users\Donie\Desktop\National_Monuments>mkdir merged C:\Users\Donie\Desktop\National_Monuments>for %f in (*.shp) do ( More? if not exist merged\merged.shp ( More? ogr2ogr -f "esri shapefile" merged\merged.shp %f) else ( More? ogr2ogr -f "esri shapefile" -update -append merged\merged.shp %f -nln Merged ) More? )
The result of the above was a merged shapefile of all 27 of the other shapefiles. As this was a huge shapefile with approximately 150,000 entries the next step was to create a PostGIS database and import the shapefile. Using pgAdmin III a postgres database was created called ‘National’ and a postgis extension was created using the following line of code:
create extension postgis;
The next step was to import the shapefile, this was completed using the PostGIS Shapefile Import/Export Manager. Only two items needed to be changed, the Spatial Reference System Identifier (SRID) was changed to 2157 (Irish Transverse Mercator) and the character encoding was changed to ‘LATIN1’.
The next step was to query the data to see what needed to be removed/edited. A simple SQL statement was run to select everything in the database:
SELECT * FROM merged;
From this 153,364 records were returned and it was clear that the column ‘classdesc’ was the column needed to find all data on ringforts. The data was then ordered using the following:
SELECT * FROM merged ORDER BY classdesc;
From examining the associated online data there are four types of ringforts that I need to export:
- Ringfort – rath
- Ringfort – cashel
- Ringfort – unclassified
The easiest way to do this was to create a new table with just those records in it and export these as a new shapefile. The following SQL script was used to create the new table:
CREATE TABLE ringforts AS SELECT classdesc FROM merged WHERE classdesc IN ('Ringfort - rath', 'Ringfort - cashel', 'Enclosure', 'Ringfort - unclassified');
Once this new table was created it was exported to a GeoJSON file using the ogr2ogr. The following was the code used:
ogr2ogr -f "GeoJSON" mydata.json PG:"host=localhost user=postgres dbname=National password=xxxxxxxx" "ringforts"
This then created a GeoJson which was uploaded to CartoDB. An intensity map was created as shown below with some custom styling for the infowindows.
If you zoom to a larger scale (such as at county level) it gives a clear indication of the intensity of ringforts at that location.
In my next post I will calculate the townland in Ireland with the largest number of ringforts.