My Strava Activities from the Same Place at the Same Time Animated

All of my activities from Strava if they started from the same place at the same time.

Strava Activites Animated

Longest activity time wise is an 11 hour walk.

Distance wise is a 200km helicopter ride.

Includes a couple of 100km cycles. But mainly walks on the beach, 5 km runs, and 10km cycles.

You can see the patterns from a number of locations that I have lived in.

How to

  1. Download your activities from Strava.
  2. Parse them into a PostgreSQL/PostGIS database with Python: https://github.com/HeikkiVesanto/StravaGarminParser/blob/master/parser_points_to_db.py
  3. Process the points to time series in the database: https://gist.github.com/HeikkiVesanto/3fbd55cda45394d069773a34ea244e4b
  4. Create animation in QGIS using the atlas generator.

Dublin Neighborhoods Mapped

Neighborhood boundaries are a fascinating topic. Where do people see their neighborhood extending to, how clear are those boundaries, and how do they shift with time.

This is a topic that has been tackled a number of times around the world, and with different types of locations (like cities). With the general public asked to draw their own neighborhood, or the ones they are familiar with, on a map. But there are challenges.

Sometimes the results are successful, like in Boston. Boston only has around 60 neighborhoods, which are relatively clearly defined based on the mapping results. And Bostonography clearly had a great readership, with over 2300 responses.

Older cities, like Glasgow are much more complex. In 2016 I did a similar survey, and from 367 responses I received 241 unique neighborhoods. You would need a much bigger set of responses to come to any real conclusions. But I still mapped the results for the West End of Glasgow, where most neighborhoods had multiple responses: Glasgow Regions Mapped

The challenges for Dublin neighborhoods is similar to Glasgow, although not as complex. But anything worth doing would require a lot of responses.

Luckily the Dublin InQuirer decided to run a similar survey, polling their subscribers for responses. The number of submissions was good, not quite beating the Boston yet, but getting close. 2200 responses and 133 unique neighborhoods mapped. They also did a few great things. One was making the data available to download. This meant that anyone could map the results, which is great. Additionally they are reaching out to areas with less responses, which is a great effort on their part.

Dublin InQuirer – Will You Draw Your Dublin Neighbourhood for Us?

Map your neighborhood.

Results:

I have mapped all of the neighborhoods as an interactive map, and individually if they had 10 or more responses.

Interactive:

Full page.

Individual Dublin Hoods:

The following have been mapped as they had over 10 responses:

Artane,
Baldoyle,
Ballinteer,
Ballsbridge,
Ballybough,
Ballyfermot,
Beaumont,
Blackrock,
Broadstone,
Cabra,
Castleknock,
Churchtown,
Clondalkin,
Clontarf,
Crumlin,
Dolphins Barn,
Donnybrook,
Donnycarney,
Drimnagh,
Drumcondra,
Dun Laoghaire,
East Wall,
Fairview,
Finglas,
Firhouse,
Glasnevin,
Goatstown,
Harold’s Cross,
Inchicore,
Islandbridge,
Kilmainham,
Kimmage,
Knocklyon,
Lower Crumlin,
Lucan,
Malahide,
Marino,
Navanroad,
Phibsborough,
Portmarnock,
Portobello,
Raheny,
Ranelagh,
Rathfarnham,
Rathgar,
Rathmines,
Rialto,
Sandymount,
Santry,
Smithfield,
Stoneybatter,
Sutton,
Tallaght,
Terenure,
The Liberties,
The Tenters,
Whitehall

Creation:

These maps were created with Python for downloading the data, PostgreSQL/PostGIS for the data processing, and QGIS for the rendering.

There is not a full tutorial, but the processing code is available in here:

Downloading the data.

SQL processing.

Every Person in Great Britain Mapped

A follow up to my previous post: Every Person in Scotland on the Map. Winner of the 2016 OS OpenData Award for Excellence in the use of OpenData from the British Cartographic Society.

Full size interactive map.

The mapping process is pretty straightforward, and not accurate. I don’t know where you live. But I can make an educated guess.

I simply amalgamate the two sets of census data from the NRS (National Records of Scotland) for Scotland (2011 census) and the ONS (Office of National Statistics) for England and Wales (2010 census).

Postcodes were then created based on the ONS Postcode Directory, filtering for postcodes that were live in 2011 (which is the latest census data). The postcode centroids were turned into polygons using voronoi polygons.

Then we simply select all of the buildings in a postcode from Ordnance SurveyOpen Map product, filtering out most schools and hospitals. Then we put a random point in a random building for each person in that postcode.

I would have loved to include Northern Ireland, but the Ordnance Survey of Northern Ireland do not have an equivalent open building outline dataset, like Open Map from the Ordnance Survey.

Rendered with: QGIS tile writer python script. Processing done 100% in PostGIS.

Copying Rasters in PostGIS

I ran into a process where I wanted to create copies of rasters in PostgreSQL. While seemingly a simple process this took me a bit of work to figure out.

For my workflow I had three rasters, which all have the same size, and I want to load them into the same PostGIS table with three raster geometry columns. I don’t think this will work for different sized rasters since the rid’s will not match.

Three rasters:
raster1
raster2
raster3

Which I want to copy into:
merged_raster

First to create the merged raster table:

CREATE TABLE merged_raster

(

  rid serial NOT NULL,

  raster1 raster,

  raster2 raster,

  raster3 raster

);

Then to add the rid’s. These are the id’s of the tiles that the raster was split into when loading. If your tile size is large enough then you may only have one.

INSERT INTO merged_raster(rid)

(SELECT rid FROM raster1);

Then copying the actual data is straighforward (this assumes the raster column in the raster1 datasets is called rast):

UPDATE merged_raster m

SET raster1 = r.rast

FROM raster1 r

WHERE r.rid = m.rid;



UPDATE merged_raster m

SET raster2 = r.rast

FROM raster2 r

WHERE r.rid = m.rid;



UPDATE merged_raster m

SET raster3 = r.rast

FROM raster3 r

WHERE r.rid = m.rid;

Now I still have an issue that QGIS will not load these layers. It will always load the initial raster column no matter what is chosen.

Creating OpenStreetMap History Visualisations

I created a couple of OSM visualisations for my talk at the OSGeo Ireland conference.

See: History of OpenStreetMap in Ireland

These are pretty easy to make, but take a fair bit of time. I did mine for Ireland, but should work with any part of the world.

Required software:

  • PostgreSQL with PostGIS
  • Python
  • QGIS
  • osmium-tools

This is the trickiest part, installing osmium-tools: here.

Data:

An OSM full history export. The best source for these is GEOFABRIK.

For Ireland:

http://download.geofabrik.de/europe/ireland-and-northern-ireland.html

Due to GDPR, you will have to log in with an OSM id to download the full history extracts. User ID’s are personal data.

Process:

The workflow is pretty simple. Osmium-tools provides pretty easy API access to the history files, where you can provide a data, and it will extract what OSM was like at that date. We simply need to loop through the desired dates we want to extract, and pipe the results into a workflow that loads the data into PostgreSQL. The final step is simply rendering in QGIS using the time manager plugin.

Python Script:

Github GIST:

https://gist.github.com/HeikkiVesanto/f01ea54cca499a6a144d18cf8909c940

The tables in the database will be:

  • lines
  • multilinestrings
  • multipolygons
  • other_relations
  • points

Each feature will be tagged with the date it is associated with.

Visualisation:

To visualise the data in QGIS we use simply use the excellent time manager plugin, filtering on the load_date field and with a monthly interval.

Result: