A CENTURY ago it would have been a key part of efforts to defend against enemy attack:

now it might exist in the form of a village hall, a long-disused guard post or just an unusual bump in the ground.

For the first time, a full audit has been undertaken to document remains scattered around Scotland which have links to the First World War.

The project, undertaken by the Royal Commission on the Ancient and Historical Monuments of Scotland (RCAHMS) and Historic Scotland, has documented sites including hospitals, prisoner of war camps, air stations, gun installations and trenches. More than 900 military and civilian places and buildings have been identified - around triple the number expected at the start of the project.

Studies of historical and contemporary maps, files and information sourced from "dusty corners" have also uncovered new information about the scale of the anti-invasion defences which were put in place to protect the country.

Previously unknown records reveal how a continuous line of barbed wire stretched from Portobello to the outskirts of Edinburgh to protect the city from an enemy attack, while a map has detailed the existence of a minefield which stretched from Scotland to Norway to stop German U-boats from getting through.

The author of the audit, archaeologist Dr Gordon Barclay, said he had raked through original records and historical maps, which may have rarely been looked at since they were filed away.

"A lot of the information has been gathered from dusty corners and now made available in a consistent way," he said.

"For example, the heavy guns which were in place round Scotland - each one of those batteries had at least one War Office file and they are preserved in the National Archives in Kew in London. Some use in the past has been made of these records, but I don't think anyone has ever looked through all of them for Scotland at once."

One key finding which was unearthed in previously unknown War Office maps was the extent of the land-based anti-invasion defences which were put in place around Edinburgh and across the Lothians and Fife to prevent enemy attacks.

A study of high-definition aerial photography also revealed surviving elements of a network of trenches dating back to the First World War, many of which had been previously thought to relate to the Second World War.

Barclay said: "There are beautifully marked maps showing in great detail the barbed wire, machine gun positions and strong points.

"For example, Liberton Tower in Edinburgh, which is now a holiday home, was a machine gun post on the defences.

"There was basically a continuous line of barbed wire entanglements all the way from the area of Seafield and Portobello to round the east and south side of Arthur's Seat.

"It stretched across to what is now Prestonfield Golf Course and then around what was then the eastern edge of the city, and to Liberton Tower and into the countryside.

"The coast defence guns in Fife also had pillboxes [guard posts], barbed wire and firing trenches all round them to protect them from an attack from the land as well."

The audit has identified 239 hospitals which were in use across Scotland during the First World War, from village halls to vast buildings that are still in use today.

It also documented 39 prisoner of war camps in locations ranging from Edinburgh Castle to the island of Raasay. The main camp located at Stobs, near Hawick, had facilities including hospitals and football pitches, and prisoners were even allowed to grow their own vegetables.

Other First World War sites include 64 air stations, 20 firing ranges, 11 naval dockyards or bases and anti-invasion defences in another 39 sites.

Allan Kilpatrick, an archaeologist with the RCAHMS, said many of the gun installations which still existed today had originally been put in place to help construct a huge minefield stretching from Scotland to Norway.

"They had only just completed the minefield by the end of the war and then they then spent the same amount of time getting rid of it," he said.

"It was a fantastic story which involved transporting mines across from America, landing them at Kyle of Lochalsh and Fort William and transporting them either by train or taking them by boat via the Caledonian Canal.

"They were protected by gun emplacements all around and it was those gun emplacements which now are really well preserved in a lot of cases, for example at the entrance to the Cromarty Firth and on the islands of Orkney.

"There are some fantastic remains, quite identifiable buildings still standing and are four gun emplacements - including one in St Kilda - which still have guns in them."

The audit has also shown that of the 350 drill halls which were in use in Scotland during the First World War, a total of 189 still survive today.

The halls, which were used as training places for volunteer soldiers, ranged from corrugated iron structures to grand buildings.

Other examples of surviving buildings include aircraft hangers at Montrose airfield and at RAF Leuchars.

The Built Heritage of the First World War in Scotland audit is being made available on the RCAHMS website, but experts are hoping that the records will be further added to with the help of contributions by the public.

"No place in Scotland is really that far from something that survives from the First World War," Kilpatrick said.

"But this is the first time we have had a comprehensive look at the First World War material.

"A lot of people think the war was all about Europe - it isn't. We have thousands of men being trained in Scotland all over the place and we have got prisoner of war camps.

"Scotland was on the front line as the German navy was this constant threat that the British had to bottle up."

He added: "Hopefully people will now be able to look at this information and look at their own area and have a wee think.

"There are lot of buildings and places that are just not in the records, not easily found and these will hopefully come out because local people know of them."

Two years ago the world's last known combat veteran of the First World War, Claude Choules, died aged 110. The world's last known surviving service member of the war, Florence Green, from Norfolk, died aged 110 in 2012.

Kilpatrick added: "We have moved from knowing lots of people who were involved in the First World War to having no-one.

"We have moved over that threshold of knowledge and this now really can quite clearly be described as archaeology in many cases."

Culture Secretary Fiona Hyslop said: "Our World War One built heritage is a vital part of our historic environment and is key to educating us about Scotland's role in the conflict. This audit will prove invaluable to our understanding of how every community played its part during the First World War.

"As we prepare to commemorate 100 years since the start of the war, I hope people will use this research to learn more about this important period and contribute any information they have so we continue to piece together a fuller picture of Scotland's role."