The recognition of ridge and valley axes is an important issue in geographic information science. Based on the similarity of digital topographic and image data structure, this paper provides a new algorithm for this purpose, which is basically deduced from the thinning algorithm used in Optical Character Recognition in the field of image processing. The erosion procedure in the thinning algorithm has been modified to sequentially consider the topographic information as a guide. As a result, the axes of ridge or valley axes can be recognized automatically and correctly by the new approach, which is also faster in execution speed and briefer in operation procedure than most existed algorithms for similar purpose.