Hi there! Welcome to this QGIS tutorial, in which I will show you how to load and display downloaded shapefiles in QGIS 3. This tutorial series will go through the same process as my introduction to ArcGIS Pro tutorial. I thought it might be interested to see how much the workflow differs between programs. I will try to follow the same steps, but since the programs are different I might be forced to take additional/different processes.
For this tutorial, we will download some data covering the capital of the Netherlands, Amsterdam. Let’s pretend we are a company owner who wants to find a new location for its Amsterdam office. It is important to us that the office:
- Can actually exist at the location, e.g. there is an empty office building.
- Is located in the central district of Amsterdam.
- Has stations close by (250 meters) so it is easy for employees to get to work.
- Has a park close by (250 meters)so that employees have the ability to enjoy their lunch outside.
I have collected a collection of shapefiles which we can use to find the optimal location to establish our new office. Let’s go through this process together. In this first part, we will download the data, load it into QGIS, and visualize it.
While you could find your own shapefiles and use these to follow along, I would recommend using the same dataset to make the examples more clear. I found some data at Amsterdams open data portal, found here: https://maps.amsterdam.nl/open_geodata/
Note that Amsterdam’s open data portal has most of their data available in GeoJSON instead of shapefiles. GeoJSON is a community-based format, and can easily be converted to other formats at http://mapshaper.org. Luckily, in contrast to ArcGIS Pro, QGIS supports reading GeoJSON, so no converting is needed!
For your convenience I have zipped the five GeoJSON files: geojson files, also giving them shorter and less Dutch names.
The 5 files:
- PARKS – Polygon feature, showing location and size of parks
- DISTRICTS – Polygon feature, showing city districts
- EMPTY_BUILDINGS – Multi point feature, showing vacant office buildings
- TRAMMETRO_LINES – Line feature, showing metro and tram lines.
- TRAMMETRO_STATIONS – Multi point feature, showing tram and metro stations. Train stations are actually not included, but since most train stations also have metro stops this should do fine.
Download the zip file, and unzip the files in a location which you can easily find later.
Short introduction to QGIS
For those of you familiar with ArcMap, QGIS will feel quite similar. Although the user interface is obviously different, the difference between the two is not as large as for example between ArcMap and ArcGIS Pro. An experienced ArcMap user should be able to get comfortable within a few hours.
Let’s take a quick look at the main elements of the UI.
The QGIS 3 window consists of six main sections:
- Menu Bar – Provides access to various QGIS features using a standard hierarchical menu.
- Tool Bar – Provides access to most of the same functions as the menus, plus additional tools for interacting with the map.
- Map Canvas – Area that displays the map.
- Layers List / Browser Panel – The browser panel on the top is a panel in QGIS that lets you easily navigate in your directories and databases. You can have access to common vector files (e.g. ESRI shapefile or MapInfo files), databases (e.g.PostGIS, Oracle, Spatialite or MSSQL Spatial) and WMS/WFS connections.
The layers list shows you a list of all the layers available to you. The checkbox in each legend entry can be used to show or hide the layer.
- Status Bar – Shows a variety of information, including the current position in map coordinates (e.g., meters or decimal degrees) of the mouse pointer. To the right of the coordinates, you will find the scale display. It shows the scale of the map view. Further right you can define a current clockwise rotation for your map view in degrees, as well access a magnifier function. Farthest to the right, you find the EPSG code of the current project CRS.Finally, the status bar occasionally shows a progress bar when a layer is being rendered in the map view.
- Data Source Manager Toolbar (new in QGIS 3.0) – Includes tools to add data to your map.
Creating a new QGIS Project
- Startup QGIS.
- On the menu bar, press New to create a new project.
- You will be met with an empty map view. This is because we are yet to add data to our empty project.
- Before we move on, let’s save our project. Find the save button on the toolbar, or press Project, followed by Save. Save the project anywhere you like.
Adding data to your project
- There are different ways of adding data to your map. One option is to open the Layer menu, press Add Layer, followed by Add Vector Layer. Then you can proceed to browse to your layers, and add them.However, QGIS 3 has introduced the data source manager. This gives QGIS a central place to add and manage all your data sources. Before QGIS 3, every type of data (fx. vector, raster, WMS etc.) all had their own button to click. The data source manager can be opened by pressing the top button on the data source manager toolbar.The following window will then open:
- On the menu to the left, press Vector, since the five GeoJSON files are of the vector type.
- Leave all options under source type as is. Press the browse button under Source, and browse to the directory where you saved your downloaded files. Select all files by control left clicking or dragging your cursor, and press Open.
Finally, back in the manager press Add. The data will get added to the map, and the map’s extent will move and cover Amsterdam. Close the data source manager.
Adding a base map with the OpenLayers plugin
While we can see our fives layers shown up on the map, it is hard to see where we are in the world without some kind of background map. In GIS we can call this a base map. In contrast to ArcGIS Pro, QGIS does not automatically add a base map to your project. While we could find a WMS service, and add a base map this way, the OpenLayers plugin provides an easy way to add all kinds of data. I use this plugin a lot!
- On the menu bar, press Plugins, followed by Manage and Install Plugins.
- The plugin management window will show. In the search bar, type openlayers.
- In the listed results, click OpenLayers Plugin.
- Click Install plugin.
- In your menu bar, click Web, OpenLayers plugin, OSM/Stamen, and finally again Stamen Toner Lite/OSM.
- This has added an OpenStreetMap WMS service to your project and gives us more perspective on the location of our added GeoJSON files. Make sure it is listed lowest in your layer list so that all other layers get rendered above it. If it is not, drag and drop the layer to the bottom of the list. Your map so far should look like this:
Do not worry about the colours of specific layers. These get set randomly. We will change the styling of them in the near future.
Showing the first data on your map
- Let’s clean things up a bit. Find the layers list on the bottom left of your screen and deselect all layers except TRAMMETRO_LINES and Stamen Toner Lite/OSM. You do this by deselecting the boxes in front of the layer names. We will use other layers later.
- You can see the small line besides TRAMMETRO_LINES. This symbolizes the symbology of this layer, and gets assigned a random colour when loading the data; in my case a purple. Let’s change that. Double click the layer in the layer list to open the layer properties window. Afterwards, click Style in the menu to the left.
- Now, we are not going to do anything difficult. Let us just change the colour to black, and increase the line width. Click the drop-down next to Color and select black. Next, in the text field next to Color, select 0,75. Your window should look like this:
Finish by clicking apply in the bottom right.
- . Your map should now look somewhat like this:
We will make this look much more interesting in the future. For now, this is just to get you familiar with where to change layer styles.
Exploring your data
Now that we have added basic styling (symbology) for rail networks, let’s take a better look at the actual data. For anyone with a basic knowledge of Amsterdam, you will know that Amsterdam has both train, tram and metro lines.
Unfortunately, our railroad feature does not include train lines. However, it would still be nice to show tram and metro lines with separate colours. But we need to be sure that our feature class distinguishes between these forms of rail transport. We can do this by looking at the data itself in an attribute table.
- Right-click the TRAMMETRO_LINES layer in the Layers Panel, and click Open Attribute Table.
This shows the attribute table in a new window.
Each record (railroad) has some data associated with it, such as a ObjectID (FID), which metro/tram routes use this section (Lijn), and whether the line belongs to the metro or tram network (Modaliteit). Bingo, that’s the information we are looking for. We can use this to symbolize the railroad, in the next part of this series.
In this tutorial, we took a first look at QGIS 3. We loaded in the data, taken a look at it, and added some simple styling. In the next part of this introduction to QGIS series, we will start showing and styling the remaining 4 layers, and we will distinguish between different fields by adding more advanced symbology. We will also do some filtering, to only show those parts of the data that we are interested in.