The Safe Software Blog
Tiana Warner
Technical content marketing at Safe Software
Get the Blog Newsletter

Delivered by FeedBurner

About Data    |   August 28, 2017   |   By Tiana Warner

3 Ways to Convert Raster Images to Vector for CAD/GIS

Extracting vector features from an image (or “vectorizing a raster”) involves converting groups of raster pixels into polygons. This is a common scenario for GIS and CAD workflows, and a challenging one. Maybe you’d like to digitize a scanned map, convert a DEM to polygons based on elevation, extract text from an image, or otherwise generate polygons from a supplied image.

There are many possible ways to tackle these problems, some easier than others, some more accurate. Here are three such ways.

1. Trace an image to convert it to CAD or GIS

Potrace is a free tool for turning bitmaps into vector graphics. In FME, you can leverage it via the custom transformer PotraceCaller. Converting raster to vector in this context involves three steps:

  1. Prepare the raster (e.g. identify color ranges in the input JPEG)
  2. Call Potrace
  3. Prepare the output (e.g. generalize polygons, style for AutoCAD)

In the below example, the user has an RGB image of an area and needs to extract CAD polygons of buildings. In the image, buildings are shown in a darker shade. Preparing the raster therefore involves classifying color ranges so the number of colors is reduced — extracting the dark shade representing buildings and leaving everything else as the background. Preparing the output involves smoothing the polygons generated by Potrace so we end up with nice blocky shapes instead of crazy 1000-sided chiliagons.

The red polygons overlaying the image have been extracted using the PotraceCaller.

Try it: Potrace Examples

Download this FME Workspace template made by Dmitri for an example of how to convert an image to a CAD drawing via Potrace. To run it, you’ll need to download Potrace, then in FME open the PotraceCaller parameters and point it at potrace.exe.

FME Workspace converting JPEG to DWG.

Or, follow this FME Knowledge Center tutorial for a step-by-step guide to using Potrace to convert JPEG to DWG.

2. Extract text from an image with Optical Character Recognition

Converting an image to text can be done by leveraging Tesseract, a free tool that performs OCR. In FME, this can be done with the custom transformer TesseractCaller.

OCR is useful for digitizing scanned maps and documents, making the data searchable and indexable. As above, this workflow also involves pre-processing steps to define color ranges, and preparing data for the output format. Read more about OCR in FME and download an example.

This scanned image of a business card has been converted to text using the TesseractCaller.

3. Extract polygons from a raster based on pixel values

This is also known as “classifying” a raster, and involves generating a polygon for each contiguous area of pixels with similar values. Like #1, this involves defining color ranges and outputting polygons based on those ranges.

In FME, do this by sending rasters through the RasterToPolygonCoercer. This transformer essentially turns pixels into polygons. While this method is simpler since it doesn’t involve downloading the 3rd-party tool Potrace, note it’s more intensive and therefore slower than Potrace. If you have a big raster, it’ll probably be more worth your while to use method #1.

This DEM has been converted to polygons using the RasterToPolygonCoercer.

Tip: For a huge raster, consider converting it to a point cloud and using FME’s superfast point cloud processing capabilities to perform your transformation of choice – e.g. group points by their component values and dissolve into polygons.


Vectorization is just one way people are incorporating images into their CAD and GIS projects. Basemaps, textures, and 3D models are a whole other area where rasters are able to speak 1000 words in terms of adding context and richness to any dataset. How are you using rasters with your CAD and GIS projects?