It was reddish soil on the feet of Sherlock Holmes's sidekick that told the detective, in The Sign of Four, that Dr Watson had been to the Post Office. In real-life crimes, too, colour is one way that forensic scientists analyse soil from a crime scene or suspect. They can also check mineral composition, the density of the soil and its pollen content. But because of the cost of using experts with the requisite skill and experience, these techniques are usually used only in serious crimes.

Now, scientists in New Zealand hope that solving crimes will be made easier and cheaper with a technique that aims to use soil and the bugs within it as a new "fingerprint" for crime. The team at the Institute of Environmental Science and Research (ESR), led by environmental microbiologist Jacqui Horswell, has developed a system that uses DNA analysis of the bacteria in soil to match samples.

"Because we can now compare the entire community (of bacteria) using DNA, we reckon we can code a soil sample based on this DNA community. So all we are looking at is the bacteria of the soil," says Dr Horswell.

To obtain a profile of the bacteria in the soil, the ESR team looks at a protein-making gene called 16S rRNA. It is a technique used regularly in environmental studies, called "terminal length restriction fragment polymorphism". What the Horswell team has done is apply it to forensics.

Once the scientists have extracted the DNA from the bacteria in the soil, they use a biological photocopier, PCR, to make copies of the DNA of the 16S rRNA gene. The next step is chop up the copies into different lengths, and it is those differing lengths, when graphed, that give the peaks which are the profile of the bacteria in that particular sample of soil. From there it is a matter of letting a computer program, developed specifically for this by ESR, figure out whether any two samples match or not.

The beauty of the technique is that it is easy to show a jury whether any two samples are the same by comparing the graphs, and - because the technique can be handled by forensic scientists familiar with molecular biology - it could be done routinely and cheaply.

Crucial to the analysis is the scientists' belief that soil samples will be unique to a specific location. For instance, the soil under a forest will be different to soil under a cricket pitch, and even the soil in two neighbouring backyards will differ depending on what is planted in the gardens. "We are basically looking at exploiting that uniqueness," Dr Horswell says.

The scientists also want to build a database of the DNA of bacteria in New Zealand soils, as that would give them the ability to say what the probability is of a fortuitous match with another soil (in the same way, the probability for a match in two samples of human DNA is calculated).

The database would also enable the scientists to suggest the provenance of an unknown soil. By putting an unknown soil's profile into the database, the scientists believe it will be possible to narrow down the type of environment the soil came from. So, for example, if the soil from a spade believed to be used in burying a victim was sandy, then police could search the beaches.

"We feel that we've proved the hypothesis that it works. Now we need to do some more validation of each bit of the method," says Dr Horswell.

The work has attracted the attention of the people who run the facility known formally as the University of Tennessee Forensic Anthropology Facility and colloquially as the Body Farm, which studies what happens to human bodies after they die. Dr Arpad Vass, a research and forensic scientist at the Oak Ridge National Laboratory, who is also attached to the body farm, is working with New Zealand doctoral studies student Rachel Parkinson.

With ESR, Parkinson is studying the bacteria that the body produces as it decomposes. By looking at soil, and the bugs from the body that have seeped into it, Parkinson hopes to create another tool to help pinpoint the time of death. "We really don't have anything for the later stages of decomposition because the periods that they can estimate are quite wide," says Parkinson.

The ESR scientists suspect that certain bugs - either from the decomposing body or those already in the soil - will flourish at certain stages, similar to the way the arrival of insects on a dead body follows a certain pattern. A bacteria timeline could be another way of estimating the time of death.

Eventually the ESR team hopes this method might not even need soil, just the fluid from a decomposing body (and the bacteria therein). "Hopefully we will understand, not necessarily what bacteria are involved with decomposition, but the changes that occur during decomposition," says Parkinson. "So we will be able to collect soil from under a body ... and compare it back to a database, perhaps of known times. Or we will be able to look for specific bacteria that we know come in at certain times as well."

Within two years, ESR plans to have developed a prototype soil-DNA analysis kit; Horswell hopes it will be ready for use in New Zealand courts in about five years' time.

"So," says Horswell, "if the person says I didn't murder her because I didn't go into that back garden, you can say, actually, I think you'll find you did."