Converting a raster to a vector
Raster datasets represent real-world features efficiently, but can have limited usage for geospatial analysis. Once you have classified an image into a manageable data set, you can convert those raster classes into a vector data set for more sophisticated GIS analysis. GDAL has a function for this operation called polygonize.
Getting ready
You will need to download the following classified raster and place it in your /qgis_data/rasters
directory:
https://github.com/GeospatialPython/Learn/raw/master/landuse_bay.zip
How to do it...
Normally, you would save the output of this recipe as a shapefile. We won't specify an output file name. The Processing Toolbox will assign it a temporary filename and return that filename. We'll simply load the temporary file into QGIS. The algorithm allows you to write to a shapefile by specifying it as the last parameter. Perform the following steps:
In the QGIS Python Console, import the
processing
module:import processing...