Getting high quality DEM data for the United States is easy thanks to the USGS. However getting any kind of DEM data for international locations can be much more difficult. This problem becomes even more challenging in time of international crisis. For example, Afghanistan has become the most overflown piece of real estate in history. Few people realize, however, that the shaded relief maps appearing on the front pages of our national publications were not produced from satellite data because that data is classified. Instead, they were derived from the most primitive but reliable source of DEM data that we have: paper topographic maps.
I recently received an email from Geoffrey Forbes describing some of the work that Eastview Cartographic has done in this area. A few skilled cartographers and commercial conversion service companies like Eastview know that it is possible to extract useful DEM data by “reverse engineering” topographic maps. The methods are not widely understood, however. This article gives some insight into the technique, and provides a helpful new software tool called BANDPASS to assist in the process.
Creation of a DEM from a topographic map requires that the elevation contours on the topo map be somehow converted to xyz data. This is done using a multi step process. The raster elevation contours must first be converted to vectors. Next, the vector contours must be “tagged” with their corresponding elevation values. The tagged vector data is then transferred to a superimposed grid by an interpolation algorithm. Finally, the gridded elevation values are written to some type of GIS format that can be used by other applications.
The conversion of raster contour data to the corresponding vectors is an interesting problem. It is also one that has been addressed by several commercial software applications, and I took advantage of one of them called R2V from Able Software. The software is available for free demo from the Able Software website at www.ablesw.com. This program has most of the utilities required to convert clean raster topo images into DEMs. With this software, your problem is reduced to obtaining a clean raster topo image for input into the program. However, this is by no means a trivial task, and from a strictly computational standpoint is a more intractable problem than the raster to vector conversion itself.
The first step is to obtain a suitable color raster image of a topographic map. Sometimes a raster topo of sufficiently high resolution will already be available in TIF or other graphic file format. Beware however of low resolution topos downloaded from the Internet. These will probably not be of high enough quality to convert successfully. As will be seen in subsequent steps, the image processing required to separate the layers will degrade the image significantly. A raster topo that looks pretty on the screen will rapidly turn to unusable mush upon multiple separation scans. In general, if your raster source is not at least as good as a USGS topo downloaded from an archive like gisdatadepot.com you will be much better off scanning a paper map to create the necessary input image.
I will use one of each type for this example. I downloaded a USGS DRG (digital raster graphic) quad for Bolton Landing, NY as one of my sources. For my other, I scanned an image from a hiking map of the Mt. Washington NH area using a standard desktop scanner. Subsets of these images are shown to the right, with Bolton Landing in Figure (1) and Mt. Washington below in Figure (2).
Unfortunately, it is not possible to convert these images directly. The contour lines, which are the only objects of interest are obscured by the other "layers" of the map. These include land use information, roads, water bodies, man made structures, text, etc. It is necessary to remove these layers and substantially clean up the image prior to the raster to vector conversion. If this is not done, neither R2V nor any other application can make enough sense of the data to create a useful DEM.
A raster image is actually not layered at all like a vector image in a CAD drawing. On the contrary, all the information is agglomerated together into an unhelpful (for our purpose) mess. It is therefore necessary to use image processing techniques to somehow separate the “layers”. Our strategy will be to take advantage of the information encoded into the RGB color values of the pixels to extract what we need and discard the rest. It is possible to separate the elevation contours from other unwanted raster data by filtering the image by pixel RGB (red-green-blue) value. In this way everything except the desired contours can be removed from the image. I wrote a utility that I call BANDPASS to illustrate this procedure. Let’s walk through it.
Open the file in Paintshop Pro. If the color depth is greater than 4 bits, meaning that there are more than 16 colors in the image, decrease the color depth by selecting 'Colors', Decrease Color Depth'. Then select 'Colors', 'Edit Palette'. Change all of the colors except the brown color representing the contour lines to white. Increase the color depth to 16 million and save in uncompressed .tif format for step (2).
An alternative technique for scanned images uses BANDPASS to screen 24 bit .tif files by entering the discrete RGB color values that you wish to retain. BANDPASS allows you to specify up to ten RGB colors. This may potentially allow greater discrimination between contour lines and unwanted objects. This is because when you reduce the color depth, each color is mapped to the palette by an algorithm that will not understand the importance of discriminating between a green color like 0x7b8d6b that is a contour line color and 0x536838 that is not.
The results from processing both inputs through the first step are shown below. Figure (3) was produced by decreasing the color depth. Figure (4) was a 24 bit scanned image run through BANDPASS. Both were saved as 24 bit .tif files for subsequent processing.
It is necessary at this point to erase any unwanted entities that still remain. It is also a good idea to connect as many broken contour lines and erase as many "orphans" as possible. I do not mean to minimize this task; it can be huge. Turning a step (1) image into a suitable input for step (2) requires a lot of tedious hand work, especially for a large map. You can click on Figure (4) to get an enlarged image. This will give you an idea of the amount of hand editing that is required at this point.
Now we are ready to run BANDPASS step (2). This step “heals” microscopic line breaks that will cause trouble later on if not fixed. The raster to vector conversion algorithm works a little like electrical current. The vectors "flow" from one pixel to the next along the contour. If there is a gap in the pixels, there will be a corresponding gap in the resulting vector. BANDPASS addresses this by using a primitive pixel dilation algorithm, in an attempt to "grow" across the gaps. A side effect is that the contour lines will thicken and potentially “bleed” into adjacent contour lines in areas of high relief. However, my experience is that it is easier to repair these bleeds than to suffer the thousands of unseen contour line breaks that is the alternative.
After completing step (2) it is necessary to again enter Paintshop Pro and examine the image one last time prior to conversion. Repair any unwanted bleeding of contour lines using the eraser tool, join any breaks and remove as many unwanted pixels as you can. A little extra work at this stage will save a lot of work after vector conversion. The images before and after running BANDPASS step (2) and manually editing are shown in figures (5), (6) and (7). (The Mt. Washington image is subsetted, shown both before and after step (2) processing.)
Now we are ready to enter R2V and finish the job. I will concentrate only on the first image (the Bolton Landing topo) from this point forward, but the technique is equally applicable to the second as well. Since the demo version of R2V will only allow you to save small files (256X256 pixels maximum), it was necessary to subset my Bolton Landing image further. This was done by simply cropping it using Paintshop Pro until the cropped section was below the limit specified by R2V (figure (8)). Now open the image in R2V and convert it from 24 bit to gray scale under the ‘Image’ ‘Conversion’ menu selections. Then simply select ‘Vector’ ‘Autovectorize’ ‘Start’. The raster to vector conversion will take place automatically. (You will know this is working by the green vectors that trace the approximate center line of the contours.)
Now it is necessary to inspect the vectors for correctness. You will undoubtedly find many unwanted “bridge” vectors between contour lines and contour line breaks in other places. These errors are a result of the complexity of the vectorization problem, and the current state of development of the underlying algorithms. The errors will need to be repaired manually. Select ‘Edit’, ‘Line Editor’, ‘Line Editor On/Off’. This will bring up the editing toolbar. You really only need two functions, the ‘Join’ function to join gaps and the ‘Delete Line’ to remove bridges.
When you have completed your repairs, you are ready to tag the contours. In this exercise, you will use two tools to assign elevation values to each contour line. First, make the elevation tags visible by selecting ‘View’ , ‘Overlay’, ‘Line IDs’. You can then start by using the ‘Label Contours’ tool. To use it you simply click on the toolbar button, and then draw a line perpendicular to and intersecting the contour lines that you want to label. When you do so, a text box will come up and ask you to input the starting elevation value and the increment. R2V will then automatically assign elevation values to the lines that you have selected (figure(9)).
There is a slight but annoying catch to this, however. For some reason the vectorized contour lines will not appear as continuous to the ‘Label Contours’ tool even though there are no visible breaks. You must watch carefully the extent of the contour lines that are highlighted during this operation to make sure that you have successfully labeled every contour line in the map. Failure to do so will result in an obviously incorrect DEM. Missed contour lines can best be labeled using the ‘ID’ tool. You use this by first selecting the ‘ID Set Value’ button. This works like the text box described above. You input the elevation of the first contour line and then the increment. As you successively click on adjacent contour lines, R2V will assign the specified elevation and increment the current elevation value as you select lines.
Once you have all your contour lines tagged, the next step is to convert the tagged image to a USGS DEM file by selecting ‘File’, ‘3D Data’, ‘Create 3D DEM File’. A text box will be presented. For a small image like this one, make sure that you set the cell size to the minimum value using the slider. This will create the highest resolution (2m) grid. Click ‘OK’ and your DEM file will be automatically created.
There is one final inconvenience to confront before you are done. The USGS ASCII DEM file output by R2V does not appear to be strictly legal: my demo file could not be read by most of my GIS applications. I fixed it by modifying the type A record using a text editor. However, the easiest way to fix it for most people is to read the file into MicroDEM (which is the most forgiving of all DEM readers) and then save it as a MicroDEM DEM file. Then use my conversion utility MDEM2DEM to convert the MicroDEM DEM file back to USGS ASCII DEM format. The result will be a USGS DEM that most applications, including 3DEM, can read.
That is what I did to create the DTM shown in the final figure. The model is rather small because of the limitations in file size imposed by the demo version of R2V. However, the techniques explained here would apply equally well to a larger file and are capable of producing as large an image as you have patience to process.
I plan to use BANDPASS.
as a testbed for additional image processing algorithms.
Thanks to Tom Neer of EDAW, Inc. for the tip on filtering contour lines by color depth reduction.
Note: the interpolation computed by R2V exhibits a lot of terracing and as a result is of relatively poor quality. Better interpolations are available that produce much smoother interpolated terrains. See my RPI Research Web Page or the Blackart Interpolation and the BLACKART v2.0 Application articles at this site for more information on contour line interpolation algorithms.
|