Start a project

Start a new project via menu or via the welcome screen. Under Project Properties you can select the correct projection and base coordinate system (see above).

Project Structure

In order to maintain some clear structure, it is usefull to first start with some planning what you want to map. In the layer window, create some layer groups where you group your different topics. For my project I created the following groups:

  • QField Mapping
  • OSM Data
  • Historical Maps
  • Public Data
    • Digital Elevation Model
    • Orthophoto
  • Base Maps

Create also the necessary folder structures to store your data. General strategy: more folders are better, as you will create a lot of files. Store every topic into a special folder.

Add Base Map

As we want to map railway stuff, OpenRailwayMap is a good first base map. Select the group Basemap in the layer list. To add the map now, we can use the plugin QuickMapServices. In the menu under “Web” select QuickMapServices - SearchNextGIS QMS. An additional dialog area should open in your QGIS GUI (bottom right in my case) with a field “Search NextGIS QMS”. Enter “OpenRailwayMap”, scroll to OpenRailwayMap - Standard in the small window below and click on Add. You now should see all mapped railway lines of the world and be able to zoom into your area to see the details.

We also want additonal data, like streets and buildings, and maybe height lines as well. With the same method add OpenStreetMap and OpenTopoMap.

On the page https://qms.nextgis.com/ you can see which web services are available as a base map via QuickMapService.

Import OpenStreetMap Data

When your railway has been mapped by OSM already, you can import the data as points, vektor and shape layer into QGIS. In our case, the “Operator” field in OSM is filled correctly, so we can filter for it. If you don’t know if there are filter criteria which work, the safest bet is just to zoom to a level where everything you want is in and then import the displayed map area.

Select the layer OSM Data. Select Vector - Quick OSM - Quick OSM from the menu. In the case you want to query for “Operator” select “Quick Query”, enter key “Operator” and “Value” the exact string you want to search for. In the dropdown below select “Map area” for the query region. If you want to search just for a substring, go to “Show Query” and substitute the “=” with a “~” to change the exact match for a “contains”. For more advanced queries check https://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide

In our case this leads to four new layers:

  • A shape layer containing buildings and platforms
  • A vector layer containing the whole route
  • A vector layer containing the individual tracks
  • A point layer containing km-stones, signals and other points.

These layers are temporary, meaning if you close QGIS now, you’ll loose them. To make them permanent, you need to save them into a file. First rename them by double clicking the layer and renaming them in the “Source” tab in the window which opens. Then click on apply and close the window (alternatively you can also use F2 to rename in the layer list directly). Click on the small symbol in the layer list next to the layer name. Save the file as a GeoPackage (no idea if this is the best format, but it works). Save it in the folder structure you generated before. A fixed convention for file naming is helpful.

After you have saved everything, it is time to style the map to get some overview. As an example let’s color bridges, main track and sidings differently. For the main track, the field “usage” contains the value “branch”, for bridges the field “bridge” is set to “yes” and for sidings the field “usage” and “bridge” are “NULL”.

Select the layer containing the track data. Select Symbol tab card. Select rule based formatting. Create new rule, as filter set “usage” LIKE ‘branch’. With “Test filter” you should get some results. Style the line to your likes (if you cannot see the line options, scroll down in the window). Add another rule with filter “bridge” LIKE ‘yes’. Style the line. Select Apply. All the tracks which are not main track or bridges should now be covered by the ELSE statement which you should have got when you first opened the conditional formatting dialogue. If there is no “ELSE” statement, add another condition and select “ELSE” as filter.

Notice that you now get selectable “sublayers” in the layer list, where you can now display and hide the different categories you created.

Let’s do something similar for the point layer. Milestones have the attribute “railway” with value ‘milestone’, level crossings have value ’level_crossing’ or ‘crossing’, switches ‘switch’, buffer stops ‘buffer_stop’, Stops (aka stations) ‘stop’, Signals ‘signal’.

For crossings the value “level_crossing” and “crossing” is used, the differences are not very clear to the author. To catch both with the same rule, the filter rule is “railway” LIKE ‘%crossing’, % standing as a wildcard for any number of characters before the word crossing.

Add publicly available maps

Public services often provide Opendata, which can be integrated into your maps in QGIS. In Bavaria, https://geoportal.bayern.de/geoportalbayern/seiten/dienste provides an overview of the map services the state provides for free or with payment fees. This includes Risk maps, topo maps, field boundaries, …

Services which are provided as WMS (Web Map Service) can be integrated easily. In the data-source browser of QGIS right click on WMS, select Add Service. Add the URL and a description in the window which opens. Apply.

Now you should have an additional data source, which shows a small arrow next to it. Open up the hierarchy by clicking on the arrow, till you get to the lowest level. The WMS maps can have multiple layers which show up on in this data source hierarchy. Select the layer you want to contain the map in the layer selector. Then double click on the wanted map layer in the source browser to add the map to your data.

If you want to create maps for your visitors, adding addtional layers from OpenStreetmap with Points of interests might be interesting. You can add them into using QuickOSM by filtering for the correct keys in OSM. Useful could be e.g.

Add historical maps

If you have historical maps or aerial photos which you want to register to your map, you can use the georeferencing tool. Note that photos and maps can be distorted, photos because they were not taken directly from above or due to lens distortion, maps due to different projections or just mapping errors. Depending on the degree of distortion you need to play around a bit with the georeferencing mode.

For now we assume that you have a historical map which is relatively accurate and just needs rotating and scaling. Go to menu “Layer” and choose “Georeferencing”. A window opens, which you can dock to the main UI, but I prefer working in a separate window. Select “File”, “Add raster” to open your image. “New points” should now be selected (globe with the green star in the menu line). Now select a point of reference in your picture which you can find in your modern basemap. A window opens, press “From map” and then select the corresponding point on the base map in the main window. Repeat for at least four points. Ensure that the points are really the same, switches and tracks might have been moved, buildings might have been rebuild, streets might move as well. It is better to have less, but certain points, than more and uncertain.

When you have sufficient points, click on the cog wheel in the menu, select transformation type “Helmert” if you just need scale, shift and rotate, select Polynomial 1 to 3 if you need more distortions (careful, might get funky). Select the file/folder where the georeferenced image should be saved. Select Compression “LZW”, to have manageable filesizes. Select “Use 0 for transparency”, to not have black borders around the image. Select “safe fit points”. Select OK. Then press the “play” buttom to actually register the image and add it to your maps.

Add your own data

In order to edit data or add data, you need to sitch the layer to edit mode. This is done by the pencil icon in the icon bar. You can then add or modify points and shapes.

If you have some data from external sources as CSV or similar, then you can add these also as a layer. One usecase for example would be mapping the cell tower signals along your line for cell phone reception. I use CellMapper on Android for this, it saves the data into a CSV file. As the CSV file does not have a header line, you need to add it manually in an editor of your choice.

In QGIS select “Layer - Add Layer - add separated text file”. Check that the options correspond to your file format, check also that the geometry definition is appleid correctly: the lat/lon fields should be identified correctly and you need to set the correct base coordinate system. For GPS data like the data from CellMapper EPSG:4236 - WGS84 is the correct coordinate system.

If your data does not show on the map, select “Zoom to layer” and check if it ended up elsehwere… If yes, you have the wrong coordinate system.

Style the layer like you need: for cell signal I chose coloring based on 10 value intervals and the signal strength as label.