THE LOST CITY OF Z ZZ Top’s original score is just a bit much.

Percival Fawcett’s name may be nothing more than an eerie coincidence, but writer/director James Gray doesn’t it treat it like one, even though his Percival was unquestionably real. “Percy” is the protagonist of Gray’s astonishing film The Lost City of Z; he’s a British officer tasked with mapping the border between Bolivia and Brazil during the first years of the 20th century. Like Arthur’s knight Percival—who spent decades obsessively seeking the Holy Grail—Z’s Percy becomes consumed by a quest that promises him glory back home until it swallows him altogether.

It’s easy to see, with just a few tweaks, how The Lost City of Z could’ve been a by-the-numbers historical biopic, and its costumes and sets are perfectly on point. But the film offers something more complicated, and as Percy and his team travel deeper into unmapped terrain, Gray takes us into uncharted territory within Percy’s psyche. Werner Herzog’s twin documents of white man’s obsession with the jungle­—Aguirre, the Wrath of God and Fitzcarraldo—are easy touchstones here, but Gray’s outlook is far more humane, and he permits his story to exist as a rip-rousing adventure for long stretches, even as it delivers much more than that.

Charlie Hunnam is excellent as Percy, and Robert Pattinson is charming in a low-key role as his sidekick, but the film’s emotional center belongs to Sienna Miller as the wife Percy leaves behind. This character could have been ordinary in so many ways, but Gray depicts her with compassion and inventiveness, and Miller fills her out in every dimension. She watches her husband grow obsessed with the idea of an ancient civilization existing in a place his British peers dismiss as a realm of savages. Percy seeks to reverse his countrymen’s imperialist outlook, but in Gray’s beautiful, haunting film, good intentions are no match for the jungle.