QGIS Tutorial Feb 2021
QGIS Tutorial Feb 2021
Developed by
February, 2021
Exercise-1: Georeferencing
Page 1 of 65
1.1 Introduction:
In order to use hardcopy maps in a GIS, they need to be scanned and
georeferenced. Georeferencing is also needed for raw remote sensing images,
such as aerial photographs and satellite images.
For the best result, choose a map sheet that is clean and does not have too many
folds. Use a scanner that is large enough to scan the whole map. The resolution
of the scanner should be large enough to have enough detail in the resulting raster
maps.
For georeferencing we need to link locations on the scanned image to coordinates.
There are two ways:
1. Collect ground control points (GCPs) at locations that are clearly visible in
the image, such as bridges and junctions.
2. If the hardcopy map contains a coordinate grid, you can use the printed
grid as a reference. Make sure that you know the projection of this grid,
which usually is stated on the map.
In this exercise we will use a scanned map of Dhaka City (Early 2000s).
1. Georeferencer GDAL
2. Coordinate Capture
3. QuicMapServices
Page 2 of 65
The installation process is shown in the following figures-
Page 3 of 65
1.4 Defining UTM manually:
1. From settings option of main window select Custom CRS…
2. In the window name the desired name of the co-ordinate system. And paste the
parameters copied from the doc file provided named “UTM parameters”.
Page 4 of 65
1.5 Importing scanned map into the Georeferencer:
Page 5 of 65
1.6 Transformation Parameters of map (To export):
First we have to set the transformation parameters of the map we are processing.
Page 6 of 65
b. Resampling method: if you need the pixel values in further calculations, it
is best to choose the nearest neighbour option. This resampling method will
preserve as much as possible the original pixel values by choosing the
nearest one. Visually, however, this method results in a “blocky” map. If
the purpose is only for visual use, for example as a backdrop for
digitization of vector layers, then it is better to choose another resampling
method. Here we will use the cubic method, which uses the average of the
4 nearest pixels.
c. Target CRS: here we can choose the code of any relevant reference system.
For our case we will choose; 32645 (which we created manually for
UTM45 N ).
Browse to the folder where you want to save the georeferenced map. The tool
automatically rename the file (as ********_modified). So in our case the
Page 7 of 65
georeferenced file will be named Test_Dhaka_modified.tif. Keep the other
settings on default and check the box Load in QGIS when done. The dialogue
should look like the one below.
Page 8 of 65
3. Enter the map coordinates in the pop-up window:
840000 2645000
Page 9 of 65
5. Repeating the same procedure we need to georeference at least 4 points.
6. If you made a mistake you can remove the GCP by using the Delete point
button .
7. At the bottom of the screen you can see the estimated mean error in the
map units (0.2530 meters in our case). The error is also indicated at the
GCPs using a red line. The large error is found, we can change to another
transformation type in the transformation settings (as shown in 1.5), the
error values will be recalculated.
Page 10 of 65
8. Now we can start georeferencing using the button. After some
calculation time the georeferenced map appears in the QGIS map canvas.
You can close the Georeferencing plugin. It will ask if you want to save
your GCPs. You can click Discard if you don’t want to use them. If you
save them, you can load them again in the Georeferencing plugin.
9. In order to verify the result you can use the Coordinate Capture plugin. If
it is not activated yet you can do it by choosing from the menu: Plugins
→ Manage and Install Plugins… . Then search for the Coordinate
Capture plugin and check the box to activate and click Close:
Page 11 of 65
Exercise-2: Digitization in QGIS
Page 12 of 65
2.1 Digitizing Vector layer from Georeferenced Background:
From a georeferenced background ( Scanned map or satellite image), we can
easily digitize vector layers. Vectors can be points, (poly)lines or polygons. In
this exercise we will do all of them.
Points:
For the CRS we select the one of the topographical background map
(USER:100000). You can use the arrow to choose the right projection
from the dropdown list. Next, we have to create a new attribute. In the
attribute list you can see that by default there is an attribute called id. We
will create one with the name Places. We can also create fields for
numbers. For type we choose Whole number and Width 3. This means that
we can store integer values up to 999.
Page 13 of 65
3. Click the button Add to attributes list. The attribute is now added. Click
OK.
4. Browse to the folder where you want to store your data and name it
Places.shpand press OK.
5. The empty shapefile has now been added to your layers list….
6. In order to start digitizing, you have to toggle to edit mode. Click on the
Places layer so it is selected.
Page 14 of 65
7. Click on to toggle to editing mode. Now the other editing buttons
become active and a pencil before the layer name shows that we are
editing the layer.
8. In the topographical map navigate to a place.Now click the Add Feature
button .
9. Now fillup the fields.
11.Repeat this step for a few other Places. If you made a mistake, you can
use to select the point feature and to delete the selected point
feature. This button can be used to move a point feature. Use
to save the edits.
12.When done, click again on the button to toggle editing. If you didn’t
save edits yet, it will ask you to Save or Discard. With Discard you can
always undo your edits until the last time it was saved.
Page 15 of 65
13.You can check the attribute table of your new point vector layer by right
clicking on the layer name (Places) and selecting Open Attribute Table..
Digitizing Line and polygon is very similar to digitizing point features. We just
have to select Line or Polygon option while adding new shapefile layer as
described in the 2nd step of the point digitizing.
Page 16 of 65
Just one thing is to be kept in mind, snapping option is a very useful option while
working with lines. We can find it in the setting option as shown below-
Page 17 of 65
2.2 Digitizing River Bank from Georeferenced Images:
In this exercise we will digitize georeferenced images downloaded from USGS
website. Downloaded images are provided in the folder named “Jamuna” inside
Ex-1.
1. First, we have toAdd images. In the main menu Click the Open Raster
button
2. Select 2007.tif and 2017.tif and double click to open.
4. Now we have to create a line shapefile using the same methods described
previously.
Page 18 of 65
5. Name the shapefile “2007Banks” (Say).
6. Now Zoom in the image and Digitize any bankline you wish.
Page 19 of 65
7. After doing the full bank the image looks like this….
8. Repeat the whole process for 20017 and name the shapefile
“2017Banks” (Say).
Page 20 of 65
9. After doing the full bank the image looks like this….
10. Hiding the images and keeping the lines only we can clearly see the
changes in only 10 years….
Page 21 of 65
Exercise-3: Vector Data Analysis
Page 22 of 65
3.1 Introduction:
In this exercise we will learn to process vector data. That will include:
Page 23 of 65
2. Now browse the CSV file, choose X,Y field and coordinate and select OK.
Page 24 of 65
3. QGIS interface will look like this.
2. In the dialogue Browse to the folder to save the file as All Cs data.shp. Select
CRS as WGS 84 UTM 45 N (EPSG: 32645). Click Ok.
3. Now Remove the All Cs data from the display by clicking right and selecting
Remove. Be sure to remove the right one. If you hover your mouse over the
layer name it will show the file name. With Remove you only remove it from
the display, the file will still be on your hard disk.
4. To check whether our points projection is ok or not, we can use google
satellite image using Quick Map Services plugin (From Web option).
Page 25 of 65
3.6 Working with Table:
Now all the elevation are in m. Let’s assume we need to convert this to ft for some
reason. Following steps will guide us through this conversion-
Page 26 of 65
3. Now the attribute table shows an extra column with NULL values. In order
to calculate the right values click above the table to open the Field
Calculator dialogue.
Fill the dialogue like the screenshot below. To avoid typos the best practice
is to double click on the field name in the middle of the dialogue screen and
to click the * button. Then type 3.28. Click OK to proceed.
4. Make sure the table look like the window below. Click update all and click
ok .
Page 27 of 65
5. Click again on to toggle back to non-editing mode. Click Save to save
the changes when asked and close the attribute table. If you made a mistake
choose Discard to undo all changes since last save.
Page 28 of 65
3.7 Interpolating point features into raster:
Now we will learn to interpolate this values of salinity into a raster.
Page 29 of 65
Check the Z-field
checkbox and
select. This is the field that we will interpolate. And choose the extent .
Page 30 of 65
4. It is visualised in greyscale, so you have to set the visualisation options. Click
right on the map and select Properties.
5. Under the Style tab, play around with the different options and click OK to
return to the display. Visualising the result this interpolation method looks
better.
Page 31 of 65
3.8 Calculating length of line features:
So far we have worked with point data only. Let’s move on to line data. Now we
are going to learn how to calculate length of line shapefile. Let’s calculate the
distances between some of the stations.
1. First of all let’s uncheck the raster layer for better visibility. Now from
coordinate layer properties, change the label to Upazila name.
2. Now create a new shapefile layer (line) as shown in the previous example.
Let’s name it as Lines.
3. Right Click on Lines and choose Toggle Editing.
Page 32 of 65
6. Repeat this procedure for all the distances that you are willing to calculate.
7. Click button to stop editing mode. Save the layer.
8. Now the window should look something like that…
9. If we go to the attribute table of the Lines layer it should look like this..
Page 33 of 65
10.We have to add a new field to calculate the lengths of the lines. For that
click on button of the table and then click on button to add a new
layer.
11.Fill up the box as shown below. [The lengths will be in meter unit, so it
might be a big number. Therefore we choose 10 as length.That means it
will be able to handle up to 999999999 m ]
12. Now for Lengths layer click button. In the geometry section find
$length and double click on it. Press ok.
Page 34 of 65
13. The table window should look like this…
Also note that the area will be in sq. meter. So we have to use field calculator to
convert it to sq. km.
Page 35 of 65
Exercise-4: Raster Data Analysis
Page 36 of 65
4.1 Necessary Data:
The necessary data (Dummy) is provided in the Ex-3 folder. For this exercise we
will use the following maps:
➢ Dhaka.tif,
➢ AREA.shp
➢ Use the add raster button from the toolbar on the left to add the
following layers: Dhaka.tif,Then click Open.
➢ Drag the Dhaka.tif grid to the top in the display tab to view the map (Note
that it is easier if the Layers panel is on top, see figure below.
➢ Rasters normally only store values, and in the layer panel it always shows
incorrect values. So we have to correct the shown values first from
properties as shown below
Page 37 of 65
Page 38 of 65
➢ Now at first do some basic operation using dhaka
4.3 Analysis:
4.3.1 Analysis -1: Basic operation using Raster calculator:
For this condition, we basically have to perform following three tasks-
➢ We can either use a shapefile (Mask Layer) or draw an extend to clip our
Raster layer (Dhaka). For our case we will use our Area file as shown
below…
Page 39 of 65
➢ Let’s Name the new file “clip Dhaka”. And also correct the legend values
as shown earlier. It will appear as shown below.
Page 40 of 65
➢ Now we can change the color properties as shown below…
➢ Now let’s find out the area with elevation over 15m.
Page 41 of 65
➢ For this go to Raster→ Raster calculator
Page 42 of 65
➢ Let the name to be “DemOver15m”. Click Save and OK.
The basic theme of inundation map is that a cell with lower elevation than the
WL will be inundated. So let’s find an inundation map for WL 9m, 10m, 11m,
12m and 14m.
Page 43 of 65
➢ If you cant find Processing Toolbox just Go to Processing and click on
Toolbox
➢ Fill us the box as shown below and click on the box at lookup table
option.
Page 44 of 65
➢ Fill up the table as shown below (before that you must Add 3 more rows
using Add row button)-
Page 45 of 65
➢ Remove the temporary file. The Raster file should look like this-
Page 46 of 65
➢ You can change label by double clicking any label. Also color can be
customized as your likings.
Page 47 of 65
Exercise-5: Map Generation
Page 48 of 65
5.1 Introduction:
In this exercise we will learn how to generate and design a standard map using
QGIS. Say for example, we are trying to generate the following map of Dhaka
District using Qgis.
1. Provide Title
2. Insert Legend
3. Insert two map frames
4. Generate Grids (With Coordinate)
5. Provide suitable borders
6. Insert Scale bar
7. Use Arrows
8. Insert image of North direction
In the following few steps we will learn how to perform all the above tasks and
thus learn the basics of map generation.
Page 49 of 65
5.2 Import Data:
The first step is to import the necessary vector or raster data layer using which
we want to generate the maps. For this exercise we will use the shapefile of
Bangladesh to generate the map of Dhaka District.
1. Add the shapefile layer named district.shp from the folder Ex-5.
2. Adjust the coordinates if necessary (we will work in BTM).
3. Extract Dhaka District from the district shapefile.
4. Use necessary adjustment of the symbology.
Page 50 of 65
2. A new composer window will pop up. Give a name or keep it blank.
4. From the Composition section, the default settings of the map can be
changed.
Page 51 of 65
5. From the page section, we can change the background of the map page as
shown in the image below (After clicking Change Button, the box of the left
will pop up).
Our basic preparation for the map is now complete. We can now insert of generate
the components of the map.
Page 52 of 65
Step-1: The Title
5. If we click on the box under the Lock icon , the text will be fixed in the current
position. We also can change the frame or background color etc.
Page 53 of 65
Step-2: The Main Frame
From main window uncheck district layer and zoom the Dhaka layer. We want
Dhaka layer in our main frame.
1. Now go to composer and click on Add new map button to create new map
layer.
2. Now create the box wherever you like in the composer window. Remember
that whatever is in the main window will automatically show up in the frame.
Page 54 of 65
3. We can use (Move/select button) to move and adjust the position of the
frame.
4. Now we can adjust the contents of the frame using the (Move item
content) button.
5. If we are satisfied with the frame position, we can lock the frame from the
item section.
6. Now our frame (Map 0) and its content is fixed in place. We can now change
its properties (background, grids, coordinates, texts etc.) from item
properties.
7. We can change the background color and provide frame from the item
properties section.
Page 55 of 65
Step-3: Grids and Coordinates
Page 56 of 65
4. Now go to the coordinate section. Fill up the section as shown below-
Page 57 of 65
6. The map should look like this now-
7. Work with the main frame is over. We will now move on to the secondary
frame containing the map of Bangladesh.
1. First of all go to the main window of Qgis and check the district layer and
zoom to layer (district).
2. Now go to composer and click on (Add new map) button to create new
map layer.
3. Draw the frame where suitable. And adjust the contents if necessary.
Page 58 of 65
4. In the Layer section check the boxes as shown above. We have to check the
boxes for the main frame also.
5. We can provide frame, grid, coordinates etc. for this frame also as shown
earlier for main frame.
6. Lock the frame in place if we are satisfied.
Step-5: Legend
1. Click on (Add new legend) button. And draw the box wherever you like.
2. Change the item properties as you wish. We can change the item names from
the Legend items section.
Page 59 of 65
4. We can also change the spacing of different components of the legend and
also provide frame and change background etc.
Page 60 of 65
Step-6: Scale bar
3. We can also change fonts and background as shown earlier. The map now
looks like this-
Page 61 of 65
Step-7: Insert North Arrow
Page 62 of 65
5.4 Export Map:
We can export the map in different formats (PDF , image etc.)
2. Select the desired folder location and click ok. A window will pop up.
Change the properties as you like.
Page 63 of 65
3. Click Save button.
4. The Image will be saved to your desired folder.
5. Using the same procedure we can export the map as PDF and SVC format
also.
Page 64 of 65