“Vectorization is the process of converting a raster into a vector.”
In this module, we will learn how to mask a raster layer and then convert the AOI(area of interest) into a vector. Vector geometry is easy to manipulate. Because of the ease of using vector geometry, we sometimes convert raster into a vector so that we can proceed with analysis.
Goal: To learn how to create mask raster in QGIS and doing raster statistics.
1 Load the raster layer specified.
2. Use the raster calculator to create a mask showing cells > 1000m = 1, and cells < 1000m = 0
Use the binary mask expression. Name the result dem_mask.tif
3. Symbolize the raster into two discrete classes.
4. Assign a no data value to the dem_mask layer so that you only show where cell values are 1.
NB: How can you calculate the area where all the cell values are 0 or 1.
5. Convert the mask layer to vector.
6. Dissolve the vector layer and edit the result to add a column for calculating area.
7. Use the expression for calculating the area and convert the total area to hectares.
8. label the resultant polygon with the area
9. Repeat the procedure from step 4 - step 8. Change the no-data value to 1.
Name | Expectation |
---|---|
Data |
srtm/ srtm_41_19.tif |
Expression |
$area |
Binary mask |
( "srtm_41_19@1" >= 1000 ) * "srtm_41_19@1" |
No Data value |
0 |
Raster data contains cell values which represent a spatial phenomenon at the cell location. Raster operations performed on multiple input raster datasets generally output cell values that are the result of computations on a cell-by-cell basis.
Raster analysis is mainly grouped into three categories which are local operations, focal operations and zonal operations. Local operations allow manipulating of the vector values by doing arithmetic operations for example reclassification to produce a binary raster. Neighbourhood operations make use of the topological relationship of adjacency between cells in the input raster to create a new raster layer.
Because raster images are generally big with a large area coverage any operations (focal, zonal and local) take time to complete and they are also influenced by the resolution of the raster image. Converting the raster to vector provides an easy option where computations are very fast.
When is it necessary to convert a raster to vector:
Why would you want to have two different map layouts using the same layer:
Can you calculate total area for raster cells greater than 100m without converting to vector:
Download the sample data for the lesson.