Our MBA students in Data Journalism produced a series of tutorials as their final project in the Low Code course: Transforming data into news stories without programming, taught by Professor Adriano Belisário. This month you can check out some of their work and... Enjoy the adventures with the tutorials they've created. Today you can check out the tutorial made by Filipo Cunha.
In this tutorial, we will see how to create maps of rivers by state or region in Brazil using QGIS and data from the National Water Agency.
Today, news reports about natural resources are increasingly common and necessary for understanding various social and economic phenomena. Our agricultural production, for example, is intrinsically linked to the distribution of water in a given region. The Northern region of Brazil has large rivers, while Rio Grande do Norte does not have entirely perennial rivers.
In this tutorial, we will be able to identify the courses of Brazilian rivers by state or region using QGIS. The goal is to provide a step-by-step guide to help visualize our hydrographic basin.
LET'S GET FIT INTO THEIR ENVIRONMENT
Today there are several georeferenced databases and maps that we can use as a starting point. I suggest using the... IBGE Map PortalHere you can find maps of various types, covering different territorial organizations, environmental information, and more. My region of interest is in the Northeast of Brazil, but if you want to create a map of states that border other South American countries, I suggest starting by downloading a map of our continent. On the IBGE Map Portal, go to the search bar: 'View by themes' – 'Charts and Maps' – 'Continuous Cartographic Bases' – choose the option 'scale of 1:250.000' – and select the option BC250 version 2017 (SHP). Several options will appear below – you should choose the option 'BC250 – VERSION 2017 SHP LIMITS'. [You'll find different scales for the map – this one covers practically everything you wanted to do] The website already has a 2019 version, but since the tip is just to get the division of the country borders, this one is smaller and will suffice for us [The 2019 package doesn't include this map of the separate borders – it's within a series of maps but it's there too].
*SHP is the shapefile extension – used when working with vector data.
To continue with our objective, we will need the map of the Brazilian states. In the same Map Portal, you will now select the option 'territory organization' at the root. Then go to 'Territorial Meshes' – 'Mesh of Federal Units' – 'Mesh with all the Federal Units' (it has the limits of our territory since 1872). Our focus is the latest update from 2020 (again in SHP). [The folders may be out of order, but just scroll down and find what you are looking for]. Downloaded? Then great! Now we can locate Brazil and the Brazilian states.
**Guys, these files are all zipped, so before you can work with them properly, you'll need to extract them to a folder of your choice.**
Obtaining river data
Now we'll need a shapefile with the rivers of Brazil – we have many options. One thing you have to ensure is finding a database that has the... variables that you need as the identifying the river by name for example, or the river compliance… A source with various maps is the ANA metadata catalogWe're going to use the Ottocoded Hydrographic Base (BHO) Multiscales of 2013To do this, enter this name in the search bar. It has a much simpler shapefile called 'rivers'.
There is another hydrographic database (2017) but although it is more up-to-date – in this tutorial I want to be able to identify the rivers and in the 2013 database there is a shapefile with all the rivers named, which is not yet available in the 2017 database.
IMPORTANT TIP
If you want more detailed work on a specific river basin, it's well worth searching the ANA website for the basin you want to explore. This way you can download only the data you need to work with.
TIME TO WORK IN QGIS
I'm using version 3.18.3 (Zurich), but it won't make much difference if you're using another version. Basically, what might change is the location of your workspace, which can be rearranged. When you open a new project, your screen will basically look like this:
The first step will be to add a new vector layer. To pull in our first map – in this case, the map of Brazil – you can go to Layer – Add Layer – Add Vector Layer, or simply find the button (that "V") for the vector layer. This one here:
Go there and find where you saved the map of Brazil – you should select the SHP file. Then simply click the add button for your map to appear as a layer.
He'll already look this cute:
To change the color, for example, you can right-click on the layer. In this case, the name is 'BRUFE250GC', and choose the 'properties' option. In 'symbols' you can choose from various types of fill, colors, opacity... In the 'Labels' menu you can assign names to the states... but that's not our goal here.
Now let's load the Brazilian rivers onto this map. We'll follow the same procedure. Add a new vector layer… find where we saved the shapefile, and add this layer. The map will look like this…
To make the processing easier, we can disable the geoft layer and work with it unchecked.
IF YOU WANT TO LOCATE A SPECIFIC RIVER…
Let's right-click on the BHO layer (the layer with the information about the rivers) and apply a filter [by clicking on filter].
In my configuration, the "Fields" side is on the right (but this may vary). We select the 'NORIOCOMP' option with a double click [for more info, consult the data dictionary here]. linkThen, in the operations section, we add the = option, and in the search for values – just click on the "all" option. All the rivers in the country will appear. Just start typing in the search field and the options will appear.
[Note: If you want to select more than one river, after choosing the first one, go to the "operators" field and select 'AND', then search for the river again.]
Important tip: many rivers have the same name, so it's good to pay attention. After typing, for example, "Rio São Francisco," several options will appear. It's important to test them and make sure that's the river you're looking for.
Now you will need to select the 'feature'.
All these small blue lines on the map are rivers called 'São Francisco', but I want to work with the famous "old Chico". When you click with the "select features" box activated (the one highlighted in the upper right corner of QGIS – next to the "T") on the river that is on the map, it will turn yellow. Now just right-click on the 'geoft' layer and export the specific feature…
A box like this will open to save the 'feature'...
NOTE: When saving, it is important to save in Shapefile format and to have the option to save only selected features checked in the encoding settings.
Simply name it, and now the São Francisco River will appear as a new layer – which you can change the color of, etc. This can be applied as many times as you want. I applied the same procedure with the Açu and Apodi/Mossoró Rivers. It turned out like this:
The rivers of a state…
But our goal is to learn how to show all the rivers in a state. It will be simpler. We'll generate two maps of Brazil: one only of the state we want to show and another without that state. Let's take Rio Grande do Norte as an example… We'll use the feature selection tool…
With the BR_UF layer of states selected, we click on the state of Rio Grande do Norte… (it will turn yellow)
Let's save the new feature just for Rio Grande do Norte [following those same steps... right-click on the Brazil map file, 'BRUFE250GC', 'Export', 'save selected features as']. Then we select all states except Rio Grande do Norte and generate another 'feature'. To select the states, just click while holding down ctrl. It will look like this…
The next step is to put the layers in the correct sequence. It works like a layer overlay, so you just need to change the order of the layers to establish priority.
Then you'll be able to view your map like this…
THE BIGGEST RIVERS…
This database shows the length of rivers, so if you are only interested in larger rivers, you can limit the rivers that appear. Simply use the 'filter' feature:
The 'NUCOMPRIO' option can be selected using operations such as =, <, >, among others… In this case, I selected only rivers longer than 30 kilometers….
Look at the difference:
FINALIZE AND EXPORT MAPS….
QGIS offers many map possibilities and can be used to illustrate and improve understanding with location data. But after these layers are ready – to have the final product – a final step is needed: the 'print composer'.
You will create a name for your composition and click on the new map….
It's important to leave some space to add the map name, observations, or data sources... and when you create the area, the map will be created automatically.
One important area is item ownership. Here you can create a frame, change the background color – which can be blue to represent the Atlantic Ocean…
Another interesting tool is the automatic generation of a scale for the map….
The text box will allow you to create titles and fonts for that map… And of course, you can open a new map under the same area to generate a better visualization!
I hope this tutorial has somehow helped you develop skills or ideas on how this tool can help you with your stories. Until next time…