Computers & Geosciences Vol. 18, No. 8, pp. 989-1001, 1992 0098-3004/92 $5.00 + 0.00
Printed in Great Britain. All rights reserved Copyright © 1992 Pergamon Press Ltd
AN ALGORITHM FOR CALCULATING MINIMUM
EUCLIDEAN DISTANCE BETWEEN TWO
GEOGRAPHIC FEATURES
DONNA J. PEUQUET
Department of Geography and Earth Systems Science Center, The Pennsylvania State University,
University Park, PA 16802, U.S.A.
Abstract--An efficientalgorithm is presented for determining the shortest Euclidean distance between two
features of arbitrary shape that are represented in quadtree form. These features may be disjoint point
sets, lines, or polygons. It is assumed that the features do not overlap. Features also may be intertwined
and polygons may be complex (i.e. have holes).
Utilizing a spatial divide-and-conquer approach inherent in the quadtree data model, the basic rationale
is to narrow-in on portions of each feature quickly that are on a facing edge relative to the other feature,
and to minimize the number of point-to-point Euclidean distance calculations that must be performed.
Besides offering an efficient, grid-based alternative solution, another unique and useful aspect of the
current algorithm is that is can be used for rapidly calculating distance approximations at coarser levels
of resolution.
The overall process can be viewed as a top-down parallel search. Using one list of leafcode addresses
for each of the two features as input, the algorithm is implemented by successively dividing these lists into
four sublists for each descendant quadrant. The algorithm consists of two primary phases. The first
determines facing adjacent quadrant pairs where part or all of the two features are separated between the
two quadrants, respectively. The second phase then determines the closest pixel-levelsubquadrant pairs
within each facing quadrant pair at the lowest level. The key element of the second phase is a quick
estimate distance heuristic for further elimination of locations that are not as near as neighboring
locations.
Key Words: Distance, Proximity problems, Quadtrees, Geographic Information Systems.
INTRODUCTION
Automated Geographic Information Systems (GIS)
that store, display, and manipulate geographic data
have become an essential tool for a wide range of
governmental and private organizations. One funda-
mental task in a GIS context is the calculation of the
minimum distance between two features. Example
applications include determining the distance be-
tween a newly discovered toxic waste site and a
nearby residential area in order to determine poten-
tial impact, or to evaluate the change in distance
between a growing urban/residential area and an
ecologically sensitive wildlife habitat through succes-
sive temporal observations. Minimum distance be-
tween two features also has importance in a range of
other application contexts, such as in Robotics where
the calculation of minimum distance is needed for
collision avoidance as a robot moves around or
manipulates specific static objects and in medical
image processing for evaluating changes in bone
mass in joints. Identifying the specific point location
on each feature that is closest with respect to the
other feature also is an essential component of
this task. Indeed, this information may be just as
important as the actual distance measure for some
Performing this task within a GIS usually is
achieved at present by a region expansion operation,
radially spreading outward from one feature uni-
formly and counting constant increments until the
first location occupied by the other object is encoun-
tered (Tomlin, 1990). Each distance increment is
counted using manhattan, chessboard, or other
distance metric as an approximation of Euclidean
distance. This process and the use of the associated
metrics was described originally by Rosenfeld and
Pfaltz (1968). They calculated a time complexity of
O(dc), where d =the number of increments and
c = the grid connectivity associated with the distance
metric used. For example, manhattan distance has
4-connectivity and chessboard distance has 8-connec-
tivity. This was improved recently upon with the use
of quadtrees by Ang and Samet (1988) and Ang,
Samet, and Shaffer (1990). This algorithm utilizes the
hierarchical nature of quadtrees and exhibits an
execution time that generally decreases as the radius
of expansion increases.
The expansion approach is the one most widely
used in a GIS context for determining distance as well
as for locating nearest neighbor, but this approach is
best suited for standard buffering operations where
all features within a prespecified distance in all direc-
tions are to be retrieved (Tornlin 1000~. Alth,~u~h