Total GRASS noob here. I have several very large hand contoured maps to digitize, and this thread intrigues me. In the past I have spent hours upon hours digitizing these maps and revisions in ArcMap. If I can save myself and my client time and money by using r.to.vect in GRASS, that would be great. The question is, to those with a trained GRASS eye, would r.to.vect even work on a scan like the sample below? I need to get the curved lines out to vectors. I'm wanting some educated eyes on this before I invest the time in learning enough GRASS to get this done. Thanks.

I need to get the curved lines out of this raster

1 Answer 1


Tough one Chad. I suspect not as a first guess. The contours are quite 'light' and the graticule lines are very thick/heavy. You will likely end up with a poor set of results. However, I can run a quick trial for you and let you know!

EDIT: Results of a trial: enter image description here

Works better than I thought, and that was without much initial cleanup. Doing the "GIMP" step (or a similar one in GRASS) would likely help quite a bit with the 'noise' (see bottom corner especially)

The process was:

  • Import your raster into GRASS
  • r.mapcalc outputfile = mask = inputfile != 255 to convert values in to zero and one
  • r.thin on outputfile from above
  • r.to.vect on the thinned raster

Like I said, some initial cleanup would help a lot, and a post vectorization clean (v.clean) would help with dangles, etc.

It may be possible to remove the graticule by calculating 'straightness' of the lines...I recall seeing a method for that somewhere, but can't remember where. Does anyone have any ideas?

Here's another shot with a bit of vector cleanup (remove dangles) applied. Again, it's getting pretty close and with some cleanup before vectorizing, would likely be even better! enter image description here

  • Darren, thanks for the advice and offer to test. I'd be willing to go over the contours with a Sharpie if that would help. Would doing the contours in a color (like red) make a difference I wonder? I'm willing to spend a little time experimenting if there is a chance at getting this to work, as could save lots of time and dollars if it does. Plus I'd love to learn how to do something in GRASS. Mar 3, 2011 at 15:26
  • 3
    The colour may help, yes. Then when you did your reclassification or cleanup in GIMP, you would be a lot more successful in picking out only what you are interested in. This would save the step of calculating 'straightness' that I mentioned to remove the graticule, and also get rid of the numbers and other random noise. I suggest you install GRASS via OSGEO4W (assuming you are in Windows) and then use it inside QGIS. This, for me, seems to be the most user friendly method. Once you get the hang of it, you can switch to one of the GRASS interfaces, or just run in command line in QGIS as well) Mar 3, 2011 at 16:33
  • Darren, thanks so much for the testing and thorough explanation of the methodology. Mar 4, 2011 at 12:22
  • Not a problem Chad! Let us know how it goes! I did a quick test of v.to.db on the output, and if you calculate 'sinuosity' you can find the straight lines (the graticule) and then remove them. It was also finding straight sections of contour though, so it perhaps needs a tweak. Possibly the 'azimuth' option would allow you to remove only vertical and horizontal lines, but I have not tried this yet. Mar 4, 2011 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.