I have .dxf file with contour lines representing elevation. But this contours are too "ugly" and elevation model looks just bad. As you can see on image, contours are not continuous... Contours and DEM created from them

Is there any way to clean up my contour lines so generated DEM will looks as it should?

So I tried terrain over TIN method and here is result. Unfortunately that pesky spots are still there. This is created from whole contour file, while first image is just cropped part of it This is created from whole contour file, while first image is just part of it

  • Which software are you using? Qgis, ArcGiS?
    – dmh126
    Commented May 3, 2014 at 14:24
  • This image is from ArcGis, but Im using Qgis and Grass as well.
    – MikeS
    Commented May 3, 2014 at 14:48
  • Are these errors present in the dxf or showing up as you bring it into GIS or perform an operation on it? If they're in the dxf, then you have a case of dirty data that you will have to clean up. dmh126 mentions some useful methods in his answer.
    – Chris W
    Commented May 3, 2014 at 18:05
  • 1
    Those spots look to be bad 'Z' values in the contours. Have you looked at the data in ArcScene or other 3d viewer? Is there an elevation or height attribute you can use as your 'Z' source instead? If all else fails and you're desperate you could fill them in help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… it's a bit dodgy but will fix the worst of the DEM problems and hopefully not introduce new ones. Commented May 4, 2014 at 22:06
  • I actually wonder if all your lines are indeed equal-elevation contours? There are some odd lines in the center of your first picture, which are perpendicular to most other lines and also seem to touch many lines. These lines don't look like contours! Although the answers below explain how to "enhance" low-quality contours, I think it is necessary to evaluate if all your lines are true contours as a very first step. A screenshot of the labeled contours would be very helpful, and also an short extract of their attributes. Also, what interpolation did you use for DEM creation?
    – lavarider
    Commented May 5, 2014 at 7:20

4 Answers 4


In ArcMap you can create topologies, and fix errors.

For your contour lines, you can create rule "Must have not dangles" because you have there a lot of gaps. After validating you will be able to extend lines and eliminate gaps. Also I saw there few lines which intersect the other ones. For them you can create rule "Must Not Intersect".

If you want you can also use Smooth tool on your contour layer. It smooths all the features in your layer.

  • This tip is good, but my file is much bigger and manually fixing all errors would be too time consuming for me. Thank you anyway.
    – MikeS
    Commented May 4, 2014 at 9:23

I've never had much luck cleaning up contours as linework. Any attempt to fix the vectors manually has been extremely time consuming and automatic methods like Smooth Line either do not enough or lead to intersections - especially the BEZIER_INTERPOLATION.

The best way I have found to produce good contours is to go back to a terrain/TIN using the contours as an elevation source, rasterize to a fairly small cell size, resample using bilinear or cubic to a slightly larger cell then resample back to the original cell size and generate new contours - either by Contour(SA) or Contour(3d).

Resampling up and down acts to smooth the raster. Of course the contours will be radically different to the original contours and will definitely not show the cuts with such detail but the result contours will be much more cartographically pleasing, and as a bonus most of this can be done in a model or manually in just a few hours rather than spending days fixing topology errors.

  • Yes, that's absolutely right. My contour file is pretty big (image here is just small part of it) with more than 20thousand errors and fixing all of them manually would be PITA.
    – MikeS
    Commented May 4, 2014 at 9:21
  • 1
    I would like to know how you generated that DEM from the contours, looks like there's some bad splining going on. Using this method would give you a good DEM that would match the contours as one is descended from the other. Commented May 4, 2014 at 9:28
  • I was using ArcMap's Topo to Raster tool. You mean method you suggested? I'll give it a try.
    – MikeS
    Commented May 4, 2014 at 9:44
  • I haven't used that one in years, I'm surprised it's still around. It is intended for hydrologically correct DEM creation.. did you supply watercourses, lakes etc.. it could be a problem with their elevation and not with the contours, but of course that's another post. Commented May 4, 2014 at 9:47
  • I don't supply anything, just my contour file. As you can see, my contour file is pretty dirty, so I don't think that is problem with their dem. And GRASS v.surf.rst did create similar dem with the same unwanted white spots.
    – MikeS
    Commented May 4, 2014 at 9:55

Doesn't look like those contours have a regular interval either and lot's of interruptions which are not necessarily dangles but could have been surveyed that way. It also seems that the source drawing file may have had breaklines in it and some areas between breaklines could have been removed. Topographic regular interval elevation contours overlaid over a DEM generated even from these contours will "look" better.

Create a TIN from the source contours then convert TIN to raster. For best results, you should add in the breaklines to the TIN. Even withou the breaklines the resulting TIN should be fine.

After you convert TIN to raster use the raster to create new contours at a regular interval.

You will need 3D analyst to create the TIN.


My file was contour file but with some ridge lines (or how its called) as well and this lines has elevation = 0. I did not know that. So I deleted all zero lines and its finally ok.

Your Answer

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

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