About four years ago, I ran into Gary Kamiya at a San Francisco Public Library sale of volumes deemed too dog-eared, outdated or infrequently checked out to continue occupying shelf space. My family and I walked off with a couple of armfuls of books. Kamiya exited with a wagon­load, a Radio Flyer stacked perilously high with novels, poetry collections, books on art and architecture and regional history and botany and God knows what else. I remember feeling a mix of bemusement and literary inadequacy — and noting his irregular gait. What had happened, I wondered, or had he always limped? But I didn’t ask, and we instead exchanged the brief pleasantries of people in the same industry. After we parted, I spotted him going back for (at least) one more load.

Now I know: It must have been just before, or soon after, the double knee-­replacement surgery that liberated him to take on a herculean task that should inspire envy in any true urbanite: to divide his city into a grid and walk nearly every block. Kamiya — who moonlighted as a San Francisco cabdriver while earning degrees in English literature at the University of California, Berkeley, en route to becoming a founding editor of Salon — calls this “doing the knowledge,” the term London cabbies have for the notoriously difficult test they must pass to earn their hack license. But Kamiya wasn’t content taking in and transmitting back the lay of the current land. Oh, no. He wanted to tell the tale of San Francisco through time as well as space, to write a kaleidoscopic homage both personal and historical, to “mix the perfect San Francisco cocktail.”

And you thought walking every block was tough! To tell the geo-politico-psycho history of a city as prismatic as San Francisco, and to do it as skillfully as Kamiya does, is no small undertaking. Yes, at approximately 46 square miles, the city is hardly immense. Its recorded history is pretty spotty before about 1800. (For context, that’s around the date at which the documentary filmmaker Ric Burns pronounced New York already too vast and complicated to be apprehended by any one human.) Nevertheless, Kamiya faced a lot of choices when deciding what to stir into his cocktail.

He employs a device beloved by writers and artists — and, it should be said, magazine editors — dating at least as far back as Katsushika Hokusai’s 1820s series of woodblock prints “36 Views of Mount Fuji.” There is an overall chronological progression to “Cool Gray City of Love,” but “space trumps time,” as Kamiya writes. The lens zooms in and out, flits about town and chooses to rest on, or bypass, parts of the city or junctures in history according to its author’s idiosyncratic tastes.