A whale shark shows off its distinct spot pattern as a scuba diver swims nearby. Simon Pierce

Whale sharks are full of creaturely contradictions. First, there’s the name: are they whales or sharks? (They’re sharks, boasting, in the words of the United Nations, “extremely numerous teeth.”) There’s the diet: despite those chompers, whale sharks dine almost exclusively on tiny plankton. This leads us to their size: like other plankton-eaters, they are surprisingly huge, often topping out at around 41,000 pounds, and stretching as long and wide as a school bus.

This, in turn, leads us to perhaps the central whale shark paradox. Even though they’re massive and gentle, it’s been very, very hard to learn anything about them. For decades, some basic facts about whale sharks—where they go, how long they live, even how many there are—eluded scientists.

A recent study in BioScience details how this is changing, thanks largely to the substantial contributions made by an online database, Wildbook for Whale Sharks. The key to this interdisciplinary, intercontinental database was similarly paradoxical. It involved taking a tool used to sift through pictures of stars and using it to identify whale sharks, instead.

A whale shark opens wide. Simon Pierce

Wildbook for Whale Sharks began as a collaboration between three people: a programmer named Jason Holmberg, a NASA astrophysicist named Zaven Arzoumanian, and Bradley Norman, a biologist who studies whale sharks at Ningaloo Marine Park in Western Australia. In 2002, Holmberg, an avid scuba diver, took a trip to the Red Sea and had a surprise encounter with a whale shark. “He was floored,” says Arzoumanian, a longtime friend of Holmberg’s. “He came away just loving the animal. He wanted to learn everything he could.”

Later that year, Holmberg went on a second whale shark trip, this time accompanying researchers on a tagging expedition. Tagging—attaching a physical object to the body of an animal—is a common method used by biologists to learn about individuals and populations. “Think of bands around the legs of birds, or tags that are attached to the ear of a deer,” says Arzoumanian.” Over time, you build up a data set.” This allows you to track migration routes, assess the health of a population, or simply follow one member over time.

Over the years, physical tagging has been augmented by technological advancements, like radio chips and removable GPS collars. Still, “traditional tagging can be invasive,” says Arzoumanian. “You have to get up close. The process might be upsetting to the animal.” It’s also doesn’t always work—whale sharks, for example, often shed their tags, or may end up far away from whatever research group originally tagged them.

A whale shark at the Georgia Aquarium. Zac Wolf/CC BY-SA 2.5

But even though they don’t do well with physical tagging, it turns out that whale sharks are great candidates for a less invasive kind: photoidentification, in which unique natural markings take the place of manmade tags. Zebras, for example, have unique stripes. Orcas have distinctive dorsal fins. Whale sharks are covered with bright white spots and lines, and each individual shark’s pattern is unique, like a giant fingerprint spread out over its head, back, and flippers. By using more traditional tagging methods on certain individuals, researchers like Norman had already established that these patterns were stable over each shark’s lifetime. Each shark might as well be wearing an ID badge.

The researchers had been scrapping together databases with the resources they had on hand. “[Norman] and others would take pictures, make prints, and store them in shoeboxes,” recalls Arzoumanian. “Every once in a while, they’d scatter them on the table or floor, get down on their hands and knees, and try to match [the spots] by eye.” While impressive, “this was not scalable,” says Arzoumanian. “Jason said, ‘Wait a minute, we’re in the 21st century now. There has to be a better way.’”

With help from Norman, Holmberg began building what would become Wildbook for Whale Sharks. Imagining participation from citizen scientists and researchers alike, he built in photo uploading capabilities and an organizational system. But one piece was still missing: the algorithm that would, figuratively speaking, get down on its hands and knees and compare whale shark spots. “When it came to the pattern matching at the heart of it, he got kind of stuck,” says Arzoumanian.

A photograph of stars and galaxies taken by the Hubble Space Telescope. NASA Goddard Space Flight Center

So Arzoumanian started talking to a colleague at NASA. Eventually, “we had collectively the realization that it’s not really two images that need to be compared—it’s the location of the spots in each image,” he says. “That made us realize that, wait a minute: this is just like star patterns.” Astronomers are always taking pictures of the sky through telescopes, he explains, and they need computer programs that can identify what patch is under scrutiny, regardless of the telescope’s magnification or the time of night.

An algorithm created by Ed Groth was already hard at work doing this for astronomers at Hubble, by exploiting the unique geometric properties of triangles. “Triangles are always the same shape, no matter how big or small they are, or whether they’re rotated,” explains Arzoumanian. The algorithm finds all possible triangles formed by the stars in an image, lists them, and compares the lists generated by different images. If the triangles match, the star patches must match as well.

Arzoumanian called up Groth, who gave his blessing. And so he, Holmberg, and Norman started messing with the star math to make it work on whale sharks. “Probably the most important tweak was making it less precise,” says Arzoumanian. “With star patterns, the geometry is always the same. The geometry of a whale shark changes: sometimes it’s swimming away or towards you, or it’s rolling left or right.” To account for the whims of a living creature, he says, “we had to make the algorithm a little sloppier.”

A Wildbook contributor photographs the left side of a whale shark. Simon Pierce

It worked, and Wildbook for Whale Sharks was up and running. Researchers and citizen scientists can upload a photo of a whale shark they’ve seen—ideally, the patch of spotted skin just behind its left gill slits—along with other relevant information, including the shark’s estimated length and the sighting location. The algorithm then figures out whether it’s a new shark or one that it already knows, and updates the files accordingly. (It also sends an email to anyone who has seen that shark before, to keep them apprised of its whereabouts.) If you include the retroactive entries scanned in from some of those scrappier pen-and-paper databases, the website has now catalogued nearly 30,000 encounters with 6,091 different sharks over 25 years.

Having all this information in one place has allowed scientists to draw new conclusions about these gentle giants. As the new paper details, researchers have identified various whale shark hotspots, including the Phillippines, the Maldives, and just off Mozambique. They are also beginning to learn more about their movements and habits, and seeing that most individuals tend to stay in the same range, rather than moving around.

The researchers are also continually improving the site. “Over the years, we’ve added other pattern-matching algorithms,” says Arzoumanian, some of which may catch matches that the original one had missed. Most of those new algorithms are borrowed, not from space telescopes, but from more contemporary endeavors: face recognition technology, for example, or self-driving cars. They are also applying the Wildbook concept to other species, including manta rays and giraffes.

Other errors are harder to anticipate. For example, the effect of the animal itself. Arzoumanian has been diving with whale sharks twice, but has no useful ID photos to show for it. “Especially the first time, I was so shocked to be in the water with this thing. It was so huge,” he says. “It was monstrous in size, gentle, and happily ignoring me. I couldn’t get my wits about me in time to take a decent picture.” We may be able to harness star math and bring it under the sea, but it’s still tough to correct for awe.