Tutorial: Digitizing in QGIS

Tutorial moved to http://www.qgistutorials.com/en/docs/digitizing_basics.html

Digitizing is one of the most common tasks that a GIS Specialist has to do. Often a large amount of ‘GIS time’ is spent in digitizing raster data to create vector layers that you use in your analysis. Quantum GIS has powerful capabilities to digitize raster data. In this tutorial, we will take some high resolution satellite imagery and digitize it to create a vector polygon layer.

The imagery we are using today is from Quickbird satellite. This particular image of Kolkata, India is made available freely by DigitalGlobe for educational use. You can download this image from http://glcf.umd.edu/data/quickbird/

The task at hand is to digitize all the water bodies from the satellite image and create a ‘waterbodies’ polygon layer.
  • Prepare and load the satellite imagery to QGIS. Once you have downloaded the data, unzip it and extract the TIF file. Load this TIF file in QGIS by clicking Layer → Add Raster Layer.
  • Browse to the TIF file and Click ‘Open’ to load the image into your project.
  • You will notice that the image seems completely black and without information. In reality, it contains a lot of information but we are not able to see it because it is very ‘low-contrast’. Right click the image layer and click on ‘Properties’. In the Propoerties dialog, click on the histogram tab. You see here that the pixels from 0-255 have some values, but the display range is from 0 -2048.
  • To display this image to a contrast level that our eyes can distinguish, we will have to stretch these pixels over a much smaller range. Once we do this, the difference between individual pixel values will be large (high-contrast) and we will see the image clearly. To do this, go to the ‘Style’ tab. Select ‘Custom min/max values’ and enter the value 500 as the max value. Then select ‘Stretch and Clip to Minmax’ under Contrast Enhancement and click OK.
  • Now you will see that the details in the image is visible clearly. Now we are ready to start Digitizing.
  • Zoom into the center part of the image so we can make out individual features. Use the ‘Zoom In’ button on the ‘Map Navigation’ toolbar to zoom and pan to the area.
  • Now create a new empty layer where we can digitize the features. Click on Layer → New → New Shapefile Layer
  • In the next dialog box, choose ‘WGS84’ as the coordinate reference system. You can choose any projection that is suitable for your region. Here we are choosing WGS84 to keep it simple. Click OK.
  • Another dialog box will pop up asking for more information about the new layer. Since we are creating a waterbodies polygon layer, choose ‘Polygon’ as the Type of the layer. Below that, there is a section named ‘New attribute’. Here you can specify what attribute information you want to collect about the features you are digitizing. These will differ from project to project, but here we will add a ‘name’ attribute. Enter the details and click ‘Add to attributes list’ button.
  • When prompted, save the layer with the name ‘water_bodies’.
  • Before we start digitizing, we need to make sure we are using the correction projection. The layer we created is in ‘WGS84’ projection, but the image is not. You can check that by right-clicking on the image layer and going to ‘Properties’. In the ‘General’ tab, you will see that the projection is UTM.
  • We need to have both our layers in the same projection before we can start digitizing. Either you can reproject the image layer to match our water_bodies layer or vice-versa. There is an easier way to do this without re-projecting by enabling ‘On-the-fly reprojection’. You can go to Settings → Project Properties
  • In the ‘Project Properties’ dialog, check the ‘Enable on the fly CRS transformation’ box. In the Coordinate Reference System box below, choose ‘WGS 84’. This will ensure that regardless of the projection, all the layers will be transformed in real time and displayed in WGS 84 coordinate system. Click Ok.
  • Once you get back to your Canvas, you will see the image is gone. This is because we are in WGS84 coordinate space and the image is not in the viewport. Right-click the image layer and choose ‘Zoom to layer extent’. The image will be back in the view.
  • Now enable the ‘Digitizing’ toolbar by right clicking in the ‘Toolbar’ section of QGIS. In the pop up menu, make sure ‘Digitizing’ box is checked.
  • Select the ‘water_bodies’ layer. Zoom to a region where you can see water bodies in the image. Then click ‘Toggle Editing’
  • Various other buttons in the toolbar will be enabled now. To start drawing a polygon, click on the ‘Capture Polygon’ button.
  • Draw the polygon by click on the edge of the visible lake. Keep clicking till the polygon is complete. Right click to join the last node to the first one and close the polygon. A dialog will pop-up asking for attribute information. Enter the ‘Id’ and ‘Name’ of the feature you just digitized and click OK.
  • Similarly, draw polygons for other features in the image. You can look at the other options in the toolbar to help you with your editing. Once you are done, click on ‘Toggle Editing’ button. In the pop-up dialog, click on ‘Yes’ to save your edits.
Now your basic digitizing is complete. You will have a shapefile with polygon features and an attribute table with ‘id’ and ‘name’ attributes. Hope you found this tutorial useful. Do leave a comment to this post with ideas, suggestions or questions relating to this feature in QGIS.