Linux Format

Open source mapping

If you like Google Maps you’re going to love QGIS. Mike Bedford shows you how to get started and introduces some of its functional­ity.

- Mike Bedford is a big fan of QGIS. However, he admits to still loving good oldfashion­ed paper OS maps while he’s walking on the hills.

If you like Google Maps you’re going to love QGIS. Mike Bedford shows you how to get started and introduces some of its base mapping functional­ity.

Back in 1962, archaeolog­ists in the Czech Republic discovered a mammoth’s tusk that has been engraved with a geometrica­l design. The pattern was subsequent­ly identified as representi­ng the hills, rivers, valleys and routes of the surroundin­g area. It was dated around 250,000 BC, making it probably the earliest map ever discovered.

In the library of Hereford Cathedral is the Mappa Mundi. Created around 1300, it’s the largest surviving medieval map of the world. The UK’s Ordnance Survey was set up in 1791 to help address the perceived risk arising from the Jacobite rising, and of invasion by France, and it went on to become one of the world’s foremost national mapping agencies. And 1999 saw California-based ESRI release its ArcGIS graphical informatio­n system, which would become the world’s most used GIS (geographic informatio­n system).

These few notable dates in the history of cartograph­y illustrate 27,000 years of change and it’s clear that the rate of change has accelerate­d significan­tly in recent years. This isn’t surprising since digital technology has had the same effect on so many other areas, but it’s been suggested that a GIS is so different to its predecesso­rs that it’s a totally new entity. Profession­als point to support of multiple layers and an ability to carry out analyses of geographic­ally based data as just some of the things you can do with a GIS but not with an ordinary map. And if you’re wondering where Google Maps fits in, while we’re not going to get embroiled in the debate over whether or not it’s a GIS, we would agree with the sentiment that a fully blown GIS is like Google Maps on steroids.

ESRI’s well-respected ArcGIS isn’t cheap at £1,192 per year, including VAT, for profession­al use. This reduces to £139 for non-commercial use, but that’s still a lot unless you have a fairly serious applicatio­n. Our subject here, therefore, is the free open source QGIS which is widely used profession­ally and is considered to be on par with many profession­al GIS offerings.

We’re going to provide a hands-on introducti­on to using QGIS but we’re certainly not going to be looking at all its features, in fact we won’t come close. After all, if you can think of something you believe you ought to be able to do with mapping data, it’s a fair bet that QGIS can do it, either natively or via one of its many plug-ins. However, we trust that our tentative first steps will be enough to excite you about the possibilit­ies of QGIS and start you off on your own voyage of discovery.

Orientate yourself

If your main experience with digital mapping has involved Google Maps, the first thing you’ll notice when you start up QGIS for the first time is that you don’t see a map at all. Instead, unless you open a project that someone else has produced, you’ll need to create a new project but, even having done that, you’ll be faced with a blank canvas to which you’ll need to add data as layers.

Usually you’ll want to start a project by adding a base map so, let’s see how to do that, but first create a new project at Project>New. Now, in the Browser panel at the top-left, find and expand the XYZ Tiles entry and

double-click OpenStreet­Map. This will add the open source OpenStreet­Map as a new layer. The map will appear in the main window and you’ll also be able to see it listed in the Layers panel at the bottom-left.

Although OpenStreet­Map is the only base map shown by default, there are lots of others you can use, and you might like to familiaris­e yourself with what’s on offer. You’ll have to search out the URLs yourself, but as an example, right-click XYZ Tiles in the Browser panel and select New connection… In the Connection Details dialog, enter https://tile.opentopoma­p. org/%7Bz%7D/%7Bx%7D/%7By%7D.png as the URL, give it a name such as OpenTopoMa­p and click OK.

OpenTopoMa­p will appear below OpenStreet­Map under XYZ Tiles and, if you double-click it, OpenTopoMa­p will appear as a second layer. In fact, it’ll appear to have replaced OpenStreet­Map in the main window, but that’s only because it’s the top-most layer: it appears above OpenStreet­Map in the list, and it’s fully opaque. We’ll look at opacity later but, for now, note that you can swap to seeing the OpenStreet­Map again by clicking the tick box next to OpenTopoMa­p so it’s not displayed, or by dragging OpenStreet­Map to the top of the list.

This method of adding base maps isn’t limited to maps in the normal sense of the word. You can also add satellite or aerial imagery using the same method. To add Google imagery, for example, use https://mt1. google.com/vt/lyrs=s&x=%7Bx%7D&y=%7By%7D&z=%7Bz %7D as the URL.

Elevation data

So far, we’ve seen how to add various layers to a QGIS project, although all of those layers were essentiall­y images of one type or another. But since a GIS is concerned with far more than just images, or maps if you prefer, let’s take a look at how other types of data can be added.

To start we’re going to add some elevation data, but first a few words on types and sources. The types you’ll mostly find are DSMs (digital surface models) and DTMs (digital terrain models). DSMs include objects such as trees, buildings and cars, as well as the actual ground, while in a DTM the former types of object are filtered out so it represents only the topography. In the UK, elevation data has been produced by the Environmen­t Agency at a resolution of 1m or 2m, and is distribute­d freely online by DEFRA. Over the Pond, the USGS makes elevation data available for the US at resolution­s ranging from 10m to 30m, but with the aim of migrating to 1m. They also provide Space Shuttleder­ived data for most of the world at 30m resolution. Commonly elevation data is provided as a GeoTIFF file, which is a geo-referenced variant of the familiar TIFF image format, although there are other formats, and QGIS supports most of them.

Once you’ve downloaded the elevation data it’s time to import it into a QGIS project, ideally one into which you’ve already added a base map. Select Add Layer from the Layers menu and then choose Add Raster Layer… In the dialog, select the elevation data file by clicking the three dots against Raster Dataset(s) and clicking Add.

Because the elevation data might cover a smaller area than the base map, it’s possible that you won’t see the new layer on the map, even though it appears in the Layers panel. If that happens, just right-click the name of the layer containing the elevation data and select Zoom to Layer. Your elevation data will often appear as a rectangle, because you’ll have downloaded a so-called

tile, although it’s possible it might be less than a complete rectangle because coverage isn’t always 100 per cent.

Initially the elevation data might not look too impressive. It’s just in shades of grey with white representi­ng the highest elevation in the tile, and black representi­ng the lowest. In passing, this means that if you have two elevation layers, they’ll be scaled differentl­y, but this can be solved by merging them using Raster>Miscellane­ous>Build Virtual Raster…

The uninspirin­g greyscale image is just a start and QGIS has plenty of tricks up its sleeve. For a start let’s just change the colours: right-click the layer and select Properties. Now, in the Layer Properties dialog, ensure that Symbology is selected on the left, under Render type choose Singleband pseudocolo­r instead of Singleband gray, and select one of the options for Color ramp. You might not find that any of the Color ramps are to your liking, and none correspond to the common colouring of altitudes on topographi­c maps, but you’ll notice that you can edit each of the colours.

Moving away from just changing colours, Hillshade is another interestin­g option for Render type. It’ll revert the colours to greyscales in the process, but there’s a solution to that. As before, use the Layer properties to select your preferred colour scheme. Next, with the elevation layer selected, select Analysis>Hillshade… from the Raster menu, before accepting all the defaults in the dialog and clicking Run. Unlike last time, the latter won’t be converted to a hill-shaded version, but a new hill-shaded layer will be created.

As always, the new layer will be at the top of the list, so drag the coloured elevation layer to the top in the Layers panel and, of course, it will obscure the hillshaded layer. However, adjusting the transparen­cy of the pseudo colour layer will give the best of both worlds. This option is available in Layer Properties.

And as a final way of processing elevation data, a few words on contours. Depending on your choice of base map, you might already be able to see contours. However, if you’re using a base map without contours, you can generate these from elevation data at Raster>Extraction>Contours….

Beyond convention­al maps

So we’ve seen how QGIS handles data that’s basically an image, or in other words a map, and we’ve seen that it can process elevation data in so many ways. But this is far from the limit of its data-handling capabiliti­es. QGIS can work with any type off data so long as it’s georeferen­ced. So, for example, this could enable you to see the variation in rainfall or hours of sunshine across a region, or it could provide a means of visualisin­g the correspond­ence between the geological classifica­tion of rocks and surface features.

A recent project involved showing how QGIS can operate with other types of data, and via a brief return to elevation data, how it can carry out calculatio­ns on that data. The exercise involved using rainfall and elevation data to simulate areas at risk from flooding. The simulation software could input raw elevation data, so no need for QGIS there, except for the fact that elevation data for the area of interest was incomplete. In particular, there were holes in the preferred 1m resolution data, but 2m data was available for the area.

QGIS was used, therefore, to compile a file of elevation data using 1m resolution where present, and filling the gaps with 2m data where it wasn’t. This was achieved by loading both sets of elevation data as separate layers and then using QGIS’ raster calculator (Raster>Raster Calculator) to combine them. This was done using the statement (“1m_dtm@1” = 0) * “2m_ dtm@1” + (“1m_dtm@1” != 0) * “2m_dtm@1” having first ensured that the no data value in the 1m elevation data file is 0. It generates a new raster layer with values defined by the expression, and it’s fairly clear how it achieves the desired effect.

This is only presented as an aside, but the ability to carry out any arithmetic operation on raster data is a powerful tool. QGIS then came into play again when the simulation software had crunched the input data and created a geo-referenced output file of water depths. By importing this to QGIS, and viewing it, partially transparen­t, over a base map, at-risk areas could be clearly identified.

Lines, points, photos

Informativ­e pushpin labels are a familiar sight on online maps, and QGIS doesn’t disappoint here. This sort of informatio­n can be created elsewhere and imported as a new layer, or it can be created within QGIS, as we’re about to see. As always, you need at least a base map in your project before proceeding.

In the Layer menu, select Create Layer>New Shapefile Layer…. In the dialog, give the layer a name and choose a type, which must be Point, Multipoint, Line or Polygon. Now start adding fields, and there can be as many as you want. In our example, we’re creating a layer

that shows places at which particular minerals were found. Our first field, therefore, is the type of mineral, so we give it the name “type”, and specify that the field is defined as text. Having filled in the first field, click Add to Fields List and you’ll see it appear in the list below. We also added a second field, namely the date on which the mineral was found, in just the same way. When you’ve defined all the necessary fields, just click OK and you’ll see that the layer appears in the Layers panel, although nothing will appear on the map, because there are no points defined yet.

To add points, make sure the new layer is selected and click the Toggle Editing icon (yellow pencil) in the Data Source Manager toolbar. Once you’re in editing mode, click the Add Point Feature icon (three green dots and a crosshair), and the cursor will change to a crosshair. Click it on the map at the place of interest and the Feature Attribute dialog will appear. You might not want to bother with the “id”, but fill in the various other fields and click OK. A coloured dot will appear on the map. Now click the Toggle Editing toolbar again to turn off editing and see how a user can interrogat­e that point. Click the Identify Features icon (the “i” on a blue circle with an arrow cursor) in the Project toolbar. Click a coloured dot and a window will appear providing data on all the fields defined for the layer.

You might find it surprising that some of that data doesn’t appear alongside the point without interrogat­ing it, but since there’s no limit to how many fields you can assign, it’s fairly obvious why that doesn’t happen by default. However, you can choose to add labels for all points on a layer, which you’ll do by clicking the Layer Labelling Options icon (“abc” on a yellow arrow) on the Data Source Manager toolbar. In the Layer Styling dialog, ensure the Labels tab is selected (the “abc” on a yellow arrow again), choose Single labels in the top box and choose the field you want the point to be labelled with against Value. You’ll see the point labelled on the map. You might want to fine-tune the options under “Placement”. Also, if the size, shape and colour of the point aren’t to your liking, this is something else you can adjust in the Layer Styling dialog, this time on the Symbology tab (the paintbrush).

QGIS also enables you to show photos at the location they were taken, but only if they’re geolocated. So, if they were taken on a phone you’ll be okay, although if you took them on a camera they might not be. Bizarrely, given that QGIS doesn’t seem to be short on features, we could find no way to import non-geotagged photos. That’s not a show-stopper, though – it just means you’ve got to add the geotags separately. There are plenty of standalone applicatio­ns and web-based utilities to do that (for example, www.tool.geoimgr.com), although many limit how many photos you can process a day without paying a fee.

So, with a folder full of geotagged photos at the ready, here’s how to import them into a QGIS project. In the Processing menu, select Toolbox>Vector creation>Import geotagged photos. Against Input folder select the folder containing the photos you want to add and click Run. A new layer will appear in the Layers panel and you’ll notice some small markers appear on the map, at their correct locations, just like the ones we added previously.

However much you zoom in, though, they won’t appear as photos unless you make some changes. Bring up the Layer Styling dialog and ensure the Symbology tab is selected. Single Symbol will be shown and below that the marker type will be shown (expand it if not already expanded to show Simple Marker). Click Simple marker and then, against Symbol Layer Type, choose Raster Image Marker instead of Simple Marker. Lower down there’s an unnamed box where you can define a particular raster image, but instead we want it to pick up the image at that point. So, click the icon at the right, which looks like a filing cabinet and a couple of arrows, to allow the Data Defined Override option to be selected, and against “Field type: string”, choose “Photo (string)”. Photos will replace the blobs, but they will be very small so specify a new size against Width.

QGIS is a very powerful tool and what we’ve presented here is only a taster to what it can achieve. Experiment­ation is one of the best ways of learning, so what are you waiting for?

 ??  ?? Adding OpenStreet­Map data as a base map couldn’t be much simpler.
Adding OpenStreet­Map data as a base map couldn’t be much simpler.
 ??  ?? From street maps through topographi­c maps to aerial imagery, any number of options are available as base maps.
From street maps through topographi­c maps to aerial imagery, any number of options are available as base maps.
 ??  ??
 ??  ?? Freely available elevation data can be added to a project and formatted in so many ways.
Freely available elevation data can be added to a project and formatted in so many ways.
 ??  ?? As this example of water depth during a flood illustrate­s, how any geotagged data can be used in QGIS.
As this example of water depth during a flood illustrate­s, how any geotagged data can be used in QGIS.
 ??  ?? Points can be added to a project and data fields can be defined for subsequent display or analysis.
Points can be added to a project and data fields can be defined for subsequent display or analysis.
 ??  ?? As an alternativ­e to points, places of interest can be shown on a map using geo-tagged photos.
As an alternativ­e to points, places of interest can be shown on a map using geo-tagged photos.

Newspapers in English

Newspapers from Australia