# How to narrow raster features to single cell width?

Are there any tools or existing workflow which convert raster features (such as roads, rivers, electric lines etc.) which are (or can be) multiple cells wide to a single cell widht (i.e, center line).

For simplicity, lets say that we have binary data: 1 = feature (whatever it is) and 0 = NoData.

Like this:

Now that's already pretty good, but how could I narrow all of those features to single cell width (using 8 node connectivity)? Looking a solution for some of the following softwares: ArcGIS, QGIS, SAGA GIS.

• please mention your software (and licence type if applicable) Nov 21, 2014 at 11:45
• Good point, although I think this can be an interesting question regardless of the software/platform. Nov 21, 2014 at 12:41

In GRASS GIS, you can use r.thin for this task:

The code implements the thinning algorithm described in "Analysis of Thinning Algorithms Using Mathematical Morphology" by Ben-Kwei Jang and Ronlad T. Chin in Transactions on Pattern Analysis and Machine Intelligence, vol. 12, No. 6, June 1990, along with further subsequent improvements.

In QGIS, you can easily use it through "Processing" >> GRASS >> raster >> r.thin.

I would suggest taking a look at the ArcScan toolbar if you are using ArcGIS. It has a range of functions in addition to Raster vectorisation which I think should help.

Specifically the Raster Cleanup tools such as erosion and dilation which will make your lines thinner. Also check out raster snapping as that may also be useful. The image below is from the Arc help files but shows the sort of cleaning / thinning that can be done using the toolbar.

Also I have used this tutorial in the past as a step by step guide to processing the raster.

With ArcGIS Spatial analyst, you can use the "thin" tool. Their algorithm is described in Zhan, Cixiang, 1993, A Hybrid Line Thinning Approach, Proceedings Auto-Carto 11, Minneapolis , pp. 396-405

As a remark, if you are interested in the process, you can also have a look at the skeletonization process in mathematical morphology. I don't know about a straightforward tool in QGIS, but there is a proximity tool that can be used to generate the result.