WELLINGTON, New Zealand (AP) — In New Zealand there are twice as many cows as people, but it’s the hobbits that are really making hay.

According to figures released last week, tourism has overtaken dairy as the nation’s top earner of overseas dollars. And tourism officials say the success of the fantasy movie trilogy “The Hobbit” has helped.

The dairy industry is struggling to recover from a slump in prices, while a record 3.4 million visitors arrived in New Zealand in the year ending September. The Pacific nation is particularly popular among tourists from Australia, China and the U.S.

Spending by international tourists was up by 20 percent in the year ending March when compared with the previous year, according to Statistics New Zealand. That follows a 17 percent rise the year before.

Kevin Bowler, the chief executive of Tourism New Zealand, said people were drawn to New Zealand by its spectacular landscapes and its outdoor lifestyle. The hobbit movies showcased some of that scenery and were heavily marketed overseas.

“The result was a heck of a lot of interest in New Zealand,” he said.

One survey showed 16 percent of tourists cited the movies as influential in their initial interest in New Zealand.

Directed by Peter Jackson, “The Hobbit” trilogy built on the success of his earlier, critically acclaimed trilogy, “The Lord of the Rings.” The six movies earned a total of nearly $6 billion at the box office.

Bowler said planned increases in flights from the U.S. and growing economies in Asia boded well for the future. The challenge, he said, would be providing enough accommodation and ensuring tourists can savor their individual experiences.

The industry got another boost this week when “Lonely Planet” named the relatively unknown Taranaki region as a place to visit in 2017. The travel guide noted an offbeat gallery there dedicated to the late artist Len Lye.

John Matthews, who chairs the Len Lye Foundation, said he was “surprised and delighted” with the inclusion.

But while tourism is booming, income from dairy products has fallen by 22 percent over the past two years, Statistics New Zealand says.

Dairy farmer Jessie Chan-Dorman, who runs 950 cows on her farm near Christchurch, said most dairy farmers have been losing money in recent years as prices for milk powder have hit record lows.

That’s due to softening demand in China for premium infant formula coupled with a glut in the worldwide supply.

Prices have begun rising again but Chan-Dorman said she remains cautious about whether that will last. It will take several years for most farmers to recover their losses, but she said she hopes many built more resilient businesses as a result.

Some farmers are cashing in on the tourism boom by offering home stays or hunting trips.

New Zealanders have long been outnumbered by their farm animals. With a population of 4.7 million people, the nation is also home to 29 million sheep and 10 million cows. And zero hobbits, of course, unless you count those on the big screen.