Animals use several strategies for depth vision, reflecting the constraints imposed by body size, the structure of the visual system and the visual geometry of the environment. Arthropods in particular have restricted depth perception, because they are small and possess closely set, low-resolution compound eyes. Yet, here we show that fiddler crabs defending their burrows from conspecifics can judge how close other crabs are to their burrow. When confronted with small dummy crabs, the burrow owners assess the dummy's position and motion relative to their burrow and not relative to themselves--in other words, by using an allocentric rather than an egocentric frame of reference. Irrespective of their own distance from the dummy, the likelihood that the crabs rush back to defend their burrow increases strongly as the dummy approaches the burrow. In addition, the mean dummy-burrow distance at which the crabs respond is constant and independent of the dummy's direction of approach. We propose that to solve this sophisticated task of relative distance judgement, the crabs combine visual information on dummy position and direction with information on burrow location acquired during path integration. In doing so, the crabs, like humans, make clever use of the visual geometry of their environment.