QGIS Time manager

Time manager is a fantastic plugin allowing you to create a time lapse video of geospatial data provided it comes with a date-time attribute. The following video shows data on where energy advice visits took place using the created date time stamp from the survey plotted every 24 hours.

Advertisements

PG routing – driving distance

Building on the work of previous posts looking at building routable networks and finding the shortest path in a network, this post will look at creating buffers around nodes based on a cost attribute specifed by the user.

The driving distance function, which comes with pg routing 2.0, creates an alpha shape around a node, normally based on the distance someone could travel from that node, or how far someone could go in a time interval.

For this example, we are looking at where someone could travel in 1km along the network from a central node. The following query selects all the nodes that are within 1 km of node 2000.

Continue reading

PG routing – shortest path algorithms

Once a routable network has been set up we can start to find the shortest path (using Dijkstra’s algorithm) between two points. From here on, I will be using the OSM data for the London road network.

The query use’s a ‘cost’ column – which could be anything thing you like – to calculate the shortest cost from one node to another. In this example I decided to use travel time (rather than distance).

First, I changed the distance of each vertex (the way table) from km to miles, and then calculated the time it would take to traverse each vertex whether walking, cycling or driving. To make this more accurate, I updated the max speed (forward and backward) along each vertex dependent on its class (as listed in the class table).

Continue reading

Geocoding

A common task within GIS is geocoding; the process of plotting postcodes within a GIS using an address locator. Cleaning the data for this process requires several steps. The format requires postcodes to be a length of 7 characters. This is easily achieved using the following formula in Excel:

=IF(LEN(A2) = 6,REPLACE(A2,3,1,MID(A2,3,1)&” “),IF(LEN(A2)=7,A2,IF(LEN(A2)=8,SUBSTITUTE(A2,” “,””))))

This works for postcodes of lengths 6,7 and 8. Other lengths can be added but it is rare you would encounter these. Save this as a csv file, ensuring the column has a header.

Continue reading

QGIS plugin: Mask

QGIS has many fantastic plugin’s, but one of these I use most in my day to day work when creating maps is the Mask tool. This allows me to either completely, or partially, mask the base map outside my area of interest, so the user can concentrate fully on the features you have mapped within their area of interest.

It’s so simple. Just select the polygons you want outside of which you want the mask and then enter the symbology parameters. I personally make the mask completely white to remove the base map but you could alter transparency levels to really bring the base map alive within the polygon.

Completely white base map outside of London boroughs

Completely white base map outside of London boroughs using a shapeburst effect

Continue reading

Extracting layers from open street map using osmosis and overpass API

Thanks to the good folk developing Open Street Map (OSM), we have a fantastic mapping resource that is completely free. Coverage is quickly expanding, as well as detail, and its these advancements that provide an opportunity to create gis layers that we would otherwise struggle to find in the public domain.

My first need of this was when I needed a shapefile of all the open/green spaces in london, and after many hours trying to locate this resource without paying a high fee or waiting several weeks, I decided to look into OSM.

OSM contributors provide a tag for every object they map, and this provides the basis for extracting objects of interest.

Firstly, we need some data! Probably the easiest place to collect this is from geofabrik. Here you can download maps at various different geographical scales in both .shp and .osm format. If you want to just extract general attributes e.g. landuse, leisure, natural etc. then downloading the shapefile can provide this straightaway. If you want to go deeper then you will need the .osm file. After the data was collected, I used two different methods to extract data.

Osmosis

Osmosis is a command line interface that allows extraction based on the key:value tag provided by the contributor e.g. landuse would be the main tag, with agriculture being a specific key under that tag. Osmosis can be easily installed on windows with instructions here.

There were two main commands I used to for extraction: Firstly to extract nodes (i.e. any object represented by a point; like a bus stop):

 osmosis --rbf layer_name.osm.pbf -–node-key-value keyValueList=”key.value” -–wx outputfile.osm

Secondly, the following was used for extracting ways (i.e. polygons):

osmosis --read-xml layer_name.osm –-way-key-value keyValueList = “key.value” –-used-node –-wx outputfile.osm

Note: Make sure you are in the directory where your map is stored.

Note 2: When extracting ways (i.e. polygons) you need to use a .osm file as the input. The tool osmconvert can easily convert from pbf to osm.
Continue reading