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. ...

Get QGIS Python Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.