I recently received a question from a BLACKART user about how to handle contour lines that are too close together. Since this is a common problem with contour maps, I thought that I would share the example in the form of a short article.
The user had prepared a fairly large, very nice contour map which is the first image at the right. However, when he attempted to tag the lines, two or more adjacent contour lines lit up with the assigned value. Not fully understanding what was going on and what solutions BLACKART offered for this problem, he fruitlessly flogged through all the menu items, looking for some relief.
The problem was that many of his contour lines were touching in one or more places. The BLACKART tagging algorithm works like electricity. The assigned elevation value "flows" from one pixel to the next, assigning the specified elevation value to each pixel until there are no more un-tagged pixels in the chain. As a result, the assigned elevation will "conduct" from one line to an adjacent line if the two lines are in contact, even if the contact occurs at the corners of two pixels. That is, each pixel in the image (except for the border pixels) is surrounded by exactly eight pixels. If any of these pixels is other than the background color (usually white) then it will be tagged. The algorithm then examines each of the eight pixels adjacent to the adjacent pixels and tags them if they are other than the background color, and then examines the pixels adjacent to these, etc. until all possibilities are exhausted.
This will create a problem in the common case where contour lines are crowded together in areas of high elevation gradient. The only solution is to manually edit the file where any two lines are touching. I cropped a subset of the problematic input file and processed it to demonstrate how this can be done. The input file is shown at the upper right.
First , I binarized the image by selecting Image|Binarize. Then I used the Graphics|Clip Text tool to erase areas where lines touched. The second image shows how I did this. I zoomed into the image and discovered the areas where adjacent lines were touching. Using the Clip Text tool surgically, I manually removed as small a section of the offending lines as possible in order to preserve as much of the original elevation contour as I could.
Then I used the Image|Digitize Contour tool to reconnect the lines properly. Note that it is not necessary for all of the lines to be connected for the subsequent interpolation to compute a solution. I purposely left two lines unconnected because I could not connect them without touching an adjacent line. Areas where contour lines are close together are areas where the data density is very high. Even if every other line is removed from the image, the data density is still higher than areas of lesser elevation gradient. The interpolation will still give a very good approximation of the surface even if it is necessary to leave some lines unconnected or with gaps.
When I was done editing, I tagged the lines. I found a line that I missed in the previous step. This is not a problem. I just disabled line tagging momentarily and enabled the Clip Text tool to "white out" the problem area. I then use the Digitize Contour tool to reconnect the lines where this was possible. When I finished, I disabled the drawing tool and enabled tagging once again and picked up where I left off before discovering the problem. The next couple of images show the repaired contour file before and after assigning the elevations. The resulting DEM and 3D terrain model are shown in the final two images.
Hopefully, this short tutorial will give some insight as to how to handle this common problem when processing topographical contour line data.
|