How is Rasterize Different From Vectorize?
Rasterization converts vectors into rasters. But vectorization transforms rasters in vectors.
We know the two main data models and graphics are vector and raster data.
But how do you go from one data model to the other?
That is when you would use rasterization and vectorization. Learn how to do this for free with open source QGIS 3. But first for some basics:
READ MORE: GIS Spatial Data Types: Vector vs Raster
What is a Vector?
Vector data are composed of vertices and paths. For example, the three types of vectors are points, polylines, and polygons.
What is a Raster?
Unlike vector data, rasters are made up of pixels or grid cells. Further to that, they are usually regularly spaced and square (but they don’t have to be) and often look pixellated.
READ MORE: 15 Free Satellite Imagery Data Sources
Rasterization: Convert Vector to Raster
In this example, we are going to use the open source program QGIS.
Unlike graphic editing software, it expects your rasters and vectors to have a geographic coordinate system. But really it has similar functionality to Adobe Photoshop or GIMP that you can perform for rasterization and vectorization.
Let’s start with a simple vector line with a vertex at the start and endpoints.
Use the Rasterize (Vector to Raster) Tool . The horizontal and vertical parameters will determine the output pixel size. After setting all the parameters, click RUN for rasterization.
Finally, the output will look like a gridded version of your vector. Depending on the pixel size you set, you may have to do some trial-and-error for better results.
Vectorization: Convert Raster to Vector
Let’s go in reverse this time and take a discrete raster and convert it to a vector.
When we have a raster data set like our buildings layer, it’s a matter of adding it to QGIS. Here’s what the raster buildings look like in the table of contents:
QGIS comes loaded with algorithms and plugins for you. Further to this, other providers like GRASS GIS, SAGA GIS, and Orfeo toolbox brings additional firepower to the table. In this case, the vectorization tool (v.to.vect) in GRASS GIS is the one you’re looking for.
Double-click the tool and select the raster that you want to convert to vector. From here, you’ll have to select the output of the raster to a point, line or polygon. After clicking “Run”, the vectorized raster will appear in the table of contents.
As a reminder, vectorization creates all the necessary vertices and paths as shown with the building outlines. In a nutshell, this tool digitizes the raster for you to convert it to a vector.
If you want to learn how to vectorize a continuous raster, this will take a bit of effort to reclassify cells essentially grouping them into discrete forms. Using a temperature raster as an example, when you group values from [-37.8 to 0] as 0 and [0 to 37.7] as 1, you are turning it into a discrete raster. From here, you can follow these same steps for vectorization.
For the most part, it’s a basic process to vectorize or rasterize images.
Rasterization refers to converting vectors into rasters. While vectorization transforms rasters into vectors.
These are the essential steps on how to go from one data model to another.
Any questions? Let us know below.