Map Preparation Using QGIS
Map Preparation Using QGIS
Map Preparation Using QGIS
INTRODUCTION
TO
Sponsored by
ILSM
ILSM
Objectives
In this module, you will be introduced to QGIS Desktop Application and will learn the following
1. Georeferencing a scanned map.
2. Map to remote sensing image registration
3. Creating a point shapefile from surveyed point features.
4. Creating line and polygon features from point features
5. Plotting contours
6. Editing contours
7. Map preparation
ILSM
ILSM
Georeferencing in QGIS is done via the Georeferencer GDAL plugin in older versions of QGIS. This is available as a core plugin in
latest version as Georeferencer- meaning it is already part of your QGIS installation. In the older versions you need to enable it. Go to
Plugins > Manage and Install Plugins and enable the Georeferencer GDAL plugin in the Installed tab (see Figure 5. 2). The plugin is
installed in the Raster menu. Click on Raster > Georeferencer > Georeferencer to open the plugin.
The plugin window is divided into 2 sections. The top section where the raster will be displayed and the bottom section where a table
showing your GCPs will appear (see Figure 5. 2.)
Now we will open our JPG image. Go to File > Open Raster. Browse to the image of the
scanned map 63b7.jpg and click Open.
In the next screen (Figure 5. 3.), you will be asked to choose the rasters coordinate reference
system (CRS). This is to specify the projection and datum of your control points. If you have
collected the ground control points using a GPS device, you would have the WGS84 CRS. If
you are geo-referencing a scanned map like this, you can obtain the CRS information from the
map itself. Looking at our map image, the coordinates are in Lat/Long. There is no datum
information given, so we have to assume an appropriate one. Since SOI datums are usually
given in WGS84 we assume the one for the map be the same.
ILSM
ILSM
You can use the zoom/pan controls in the toolbar to learn more about the
map (Figure 5. 5).
ILSM
Now we need to assign coordinates to some points on this map. If you look closely, you will see coordinate grid with markings. Using this grid,
you can determine the X and Y coordinates (or Northing and Easting) of the points where the grids intersect. To find the intersections zoom in at
the image corners. Then click on Add Point in the toolbar. Now click on the intersection of the grid lines (Figure 5. 6)
You will notice the GCP table now has a row with details of your first GCP (Figure 5. 7.)
ILSM
Similarly, add at least 4 GCPs covering the entire image. The more points you
have, the more accurate your image is registered to the target coordinates.
ILSM
ILSM
10
ILSM
scroll to the shoe shape object in the image and the corresponding map 63b7_modified.tif in the Layer panel (Figure 5. 10).
Figure 5. 10: Shoe shaped object as displayed in the image and the map
11
ILSM
For Georeferencing the image, we must add tie points from the map to
the image. Identify the suitable corners in the shoe shaped object for tie
points.
In the Georeferencer tool, zoom into the selected corner and select
Add Point tool. Click on the identified corner (Figure 5. 11).
We do not know the coordinates of this point, to add the coordinate
from the map, locate the same (approx.) point in the map. Now go
back to the Georeferencer tool and select From map canvas and
then return to the map and click at the corresponding point. The
coordinates are transferred to the Enter map coordinates window.
Select OK. The point is added in the GCP Table.
Similarly add 5-6 uniformly distributed points, such that the
transformation does not entail directional dependency.
You can see the tie points and their distribution. Select View> Zoom
to Layer. Now zoom in to the shoe shaped object to clearly identify
the selected tie points (Figure 5. 12).
Once you have enough points, go to Settings > Transformation
settings.
In the Transformation settings dialog, choose the Transformation
type
as
Linear.
Name
your
output
raster
as
imagery_modified.tif. Choose EPSG: 4326 as the target SRS so the
resulting image is in a widely compatible datum. Make sure the
Load in QGIS when done option is checked. Click OK.
Back in the Georeferencer window, go to File > Start
georeferencing. This will start the process of warping the image
using the GCPs and creating the target raster.
Once the process finishes, you will see the georeferenced layer
loaded in QGIS (Figure 5. 13).
12
ILSM
13
ILSM
14
ILSM
15
ILSM
16
ILSM
This opens the coordinate reference system
selector window. Select WGS84/UTM zone
44N, EPSG: 32644 for the datum and projection
system. The points are shown in QGIS with a
layer added in the Layers Panel (Figure 5. 16).
To visualize the points by their attributes,
select this layer in the Layers Panel and right
click. Now select Properties. This opens the
Layer Properties dialogue (Figure 5. 17).
17
ILSM
18
ILSM
19
ILSM
20
ILSM
21
ILSM
22
ILSM
23
ILSM
24
ILSM
25
ILSM
26
ILSM
27
ILSM
In the New Shapefile Layer dialogue, select the options as marked in a red box shown in Figure 5. 27. Now click on Add to fields list. This
adds the field Name in the attribute table of the shape file as shown in Figure 5. 27. In the Name field, we can add the name of the building,
for example Western Lab Extension-WLE in this case. This new shapefile is added to the Layers Panel.
Geoinformatics, Civil Engineering, IIT Kanpur
28
ILSM
This shapefile is empty and we must add feature to this using the building points shapefile. For this click on the polygon building shapefile in
the Layers Panel, Now, click on the Toggle Editing tool marked with a pencil symbol and then on the Add feature tool, the second next
symbol to the Toggle Editing tool (see Figure 5. 28).
29
ILSM
Now, click on the points to connect them from the building points to create a polygon. At the last vertex of the polygon, you need to right click.
This opens the attribute window, where you can save the buildings name.
After this the polygon is saved in the shapefile as shown in Figure 5. 29. You can view the attribute table for this and see that the given name
is added to the field Name.
Figure 5. 29: Saved polygon for the building with attribute information
30
ILSM
You can change the symbol and the fill using the Style dialogue in the Layer Properties.
Similarly, we create a new Line shapefile for the roads. Follow the same procedure as done for creating a polygon for building. In this case
the points are connected to lines and terminated by right clicking on the end point. This gives you the attribute window to save the name of
the road, which is then added to the attribute table of the layer. This is shown in Figure 5. 30.
31
ILSM
32
ILSM
5. Plotting Contours
Generate a point map as done previously. Creating a shapefile from surveyed points and features.
Go to Raster>Interpolation>Interpolation (Figure 5. 32). This loads the
Interpolation Plugin (Figure 5. 33). In older versions of QGIS this plugin was to
be installed externally. However with newer versions, this is one of the core
functionalities.
In the Interpolation Plugin on the left in the Input panel, select the field with
the elevation values for the points in the Interpolation attribute and click Add.
There are two predefined methods for interpolation in the Interpolation Plugin
Triangular Irregular Network (TIN) and Inverse Distance Weighing (IDW). In
the Output panel select IDW in the Interpolation method tab. Then click on
Set to current extent.
Provide the output directory for the raster by browsing to your desired location
and name the output raster. Make sure Add results to project is checked. Then
click on OK.
33
ILSM
34
ILSM
35
ILSM
36
ILSM
6. Editing Contours
The contour lines do not pass through buildings or other man made features. In our example, the only prominent manmade feature is
the WLE building. Thus we need to mask the contours that pass through this building, for this we will make use of the Clip and the
Difference tool.
Clipping is performed to hold the contours inside a polygon and omit the contours lying outside the polygon. Thus, we may perform
the vector clip operation over two polygons one for the building and the other for another polygon whose area covers the area which is
needed to be mapped. After that we can take the difference of the two clipped layers to eliminate the contours outside the feature area
and inside the building.
First, we will clip the building polygon as shown in Figure 5. 37 and Figure 5. 38.
In the 'Clip' tool, select the contour layer for the 'Input vector layer' and the building polygon layer for the 'Clip layer', as in Figure 5.
38.
The final contours clipped within the building polygon are shown in Figure 5. 39.
Similarly, we perform the clipping operation on a newly created polygon (Figure 5. 40) for the mapping area. This will eliminate the
contours outside the mapping area, as shown in Figure 5. 41.
Now we will use the 'Difference' tool to eliminate the contours inside the building polygon (Figure 5. 42). In the 'Difference' tool, select
the earlier clipped layer for mapping area as shown in Figure 5. 41 as 'Input vector layer' and the clipped layer for the building polygon
as 'Difference layer'. The differencing operation is shown in Figure 5. 43, while the output is shown in Figure 5. 44.
To add the labels go to the 'Labels' tab. Select in the first menu 'Show labels for this layer' and label with elevation values as shown in
Figure 5. 45.
To correct the placement of the labels over the contour, go to the 'Placement' menu and change the contour label to 'Horizontal' (Figure
5. 45). Now, go to the 'Background' menu and select 'Draw background' and 'Shape' as 'Rectangle' as shown in Figure 5. 46. This is to
place the labels in corresponding to SOI norms.
Now, we will change the look of the contours. For this go to the 'Style' tab and then change the first menu to 'Categorized' and select
the elevation values in 'Column', then click on 'Classify' as shown in Figure 5. 47.
Now change the color of each of the contour to 'burnt sienna' and increase the width of every 5th contour.
37
ILSM
38
ILSM
39
ILSM
40
ILSM
Figure 5. 40: Polygon to mask the contours outside the map area.
41
ILSM
42
ILSM
43
ILSM
Figure 5. 43: Performing the difference operation between the clipped contours
44
ILSM
45
ILSM
46
ILSM
47
ILSM
48
ILSM
7. Map Preparation
Keep in the 'Layers Panel', only those layers which you need for the map. Make sure for each feature you have a single layer.
To create the map, go to 'Project' in QGIS menu bar, and select 'New Print Composer', this opens a 'Composer title' dialogue as shown in
Figure 5. 48. Give an appropriate title to the composer and select 'OK'. This will open the composer window.
In the composer window, select 'Add new map' (Figure 5. 49).
Now click on the white space and drag a box. The map from the QGIS Desktop window will appear in the white space. To move the map
content press 'C' on the keyboard and drag the content to the desired location (Figure 5. 50). To enlarge the map, use the mouse scroll button.
To add title to the map, go to the 'Layout' menu and select 'Add Label' (Figure 5. 51). Now click at top center of the white space (Map area)
and drag a box. Now, in the 'Item properties' panel on the right edge, enter the title.
To add the north arrow, download a north arrow image from your browser. Select the 'Add Image' option in the 'Layout' menu. Now, drag
a box at the top right corner of the Map area. In the 'Item properties' menu give the path to the downloaded north arrow image as shown
in Figure 5. 52. Resize the box to set the size of the north arrow.
To add the Legend, go to the 'Add Legend' option in the 'Layout' menu. Now, drag a box at the bottom left or bottom right corner of the
map area (Figure 5. 53). You can adjust the appearance of the legend using the 'Item properties' menu.
To add the scale bar go to the 'Add Scalebar' option in the 'Layout' menu. Drag a box where you want to put the scalebar. 'Item properties'
can be used to change the appearance of the scalebar. For the representative fraction add another scalebar over the top of the previous one.
In the 'Item properties', within the 'Main properties', select 'Style' as 'Numeric' (Figure 5. 54).
In the 'Items' menu select the Map. To add the grid, go to 'Item properties' and add a new grid within the 'Grids' option. Now change the
grid settings as required (Figure 5. 55).
Note, to freeze the elements in the map, check the lock option for the item in the 'Items' menu.
The final map in our example is as shown in Figure 5. 56.
49
ILSM
50
ILSM
51
ILSM
52
ILSM
53
ILSM
54
ILSM
55
ILSM
56
ILSM
57
ILSM
58