By David Stanway

HELIN, China (Reuters) - Deep in the coal heartlands of northern Shanxi province, people in Helin village are fighting a losing battle as the ground beneath them crumbles: patching up cracks, rebuilding walls and filling in sinkholes caused by decades of coal mining.

Around 100 pits in Helin - buried in the hilly rural outskirts of the city of Xiaoyi - have been exhausted, and cluttered hamlets totter precariously on the brittle slopes of mines.

But while local authorities have begun evacuating hundreds of thousands of residents most at risk elsewhere in Shanxi province, Helin's situation – though serious - isn't yet considered a priority.

"We haven't been told to leave yet, but when the government gives us the order, we'll be happy to go," said Wang Junqi, who lives in a one-room tenement with his family. "It isn't safe here and the people who have a bit of money have already gone. It's scary, but what can we do?"

Mines that burrowed under villages and towns during China's three-decade coal boom have left the authorities with the need to evacuate hundreds of communities in danger of sinking.

Shanxi province alone plans to move 655,000 residents by the end of next year from unsafe old mining regions, with the cost of relocation estimated at 15.8 billion yuan ($2.37 billion). The Shanxi government estimates coal mining has cost the province 77 billion yuan in "environmental economic losses".

GEOLOGICAL DISASTERS

Mine-induced subsidence is not unique to China, but its problems dwarf those of other countries.

A notice board at a deserted Communist Party building in an abandoned village not far from Helin gives an idea of the scale of the disaster.

It lists 19 geological "disaster zones" spread across 23 villages, 55 landslides, 950 cracks in the ground and 808 incidents of mine subsidence -- all in an area of just 13.25 square kilometers (5 sq miles)

According to official data, coal mining had already caused as many 26,000 geological disasters by the end of 2014, and as much as 10,000 square kilometers of land has been affected, an area the size of Gambia in Africa, according to some estimates.

China's land ministry said last month it would spend 75 billion yuan ($11.27 billion) over the next five years to restore mined land and treat mining waste nationwide.

The growing environmental bill comes at a time when China's stricken coal sector faces mounting debts, falling demand and a long-term decline in prices after the boom turned into a bust.

BOON TO BURDEN

The coal sector, as with other basic industries in China such as steel, is now saddled with overcapacity estimated at around 2 billion tonnes a year, as demand growth slows and the country promotes cleaner forms of energy. China planned to close around 1,000 collieries this year alone, many of them in residential areas such as Helin, as it cuts coal's share of total energy consumption to 62 percent by 2020.

During the boom years, as prices and profits soared, miners were encouraged to dig further and deeper, encroaching upon residential areas and farmland.

While large state-run firms would often relocate entire villages, smaller private miners, chasing quick profits, simply dug under and around communities. With mining tax revenues surging, local governments were reluctant to impose stricter controls on the industry.

The industry helped pay for construction binges like one in Xiaoyi, where Helin is located, topping up local government tax coffers and bestowing the city center with rows of largely unoccupied luxury apartment blocks.

What was once a boon for governments has now turned into a burden: Xiaoyi has already spent more than 6 billion yuan ($901.31 million) to treat subsidence, the government said. Together with the neighboring city of Luliang, it plans to relocate as many as 230,000 people over 2014-2017.

Little of the money to move communities and restore the land is coming from the miners themselves, although that was supposed to be the plan in the beginning.

Miners are required to pay "subsidence fees" to pay for the cleanup when their mines close. The Datong Coal Industry Group <601001.SS>, the only state miner to give breakdowns, paid just 1.4 million yuan in those fees from January to March this year, or 0.04 percent of its total costs, according to its quarterly report.

SOLAR SOLUTIONS

Jiang Jian, a legislator from Shandong province, said Beijing needed to draw up detailed measures to determine how much mining firms should pay.

Many of the worst-hit sites have been long abandoned, making it harder to decide who is responsible, she noted, so Beijing also needed to set up dedicated funds to help pay remediation costs, including treatment and disposal of mine waste.

To help with the clean-up, China is encouraging developers to turn abandoned mining sites into wind and solar power projects. Solar accounted for just 0.6 percent of China’s overall electricity generation from January to June, and wind was a mere 3.6 percent.

One solar demonstration project has been completed in the eastern outskirts of Datong, also in Shanxi, on ground damaged from mining and not suitable for farming.

The area was once a prosperous coal region with more than 1,000 mines, but extraction stopped after the collapse in prices, and the local economy cratered.

"Before we got here this piece of land wasn't suitable for any kind of planting, but now at least some of it can be used," said He Xin, project manager with the United Photovoltaics Group <0686.HK>, which owns and operates a 100-megawatt solar farm at the site.

(Additional reporting by Natalie Thomas and Jason Lee. Editing by Bill Tarrant)