Despite South Africa's dramatic departure from the weekend Namibia talks, an internationally acceptable agreement under which a new nation will emerge from the territory of Southwest Africa appears much closer today than seemed possible a year ago.

The five western powers - the United States, Britain, France, West Germany and Canada - have greatly narrowed the gap separating South Africa, which has ruled the territory since World War I, and the Namibian liberation group known as SWAPO (Southwest Africa People's Organization).

In fact, it would seem that the negotiating gap is not that great - certainly nothing compared with the complexities of the Rhodesian talks.

Basically, South Africa and SWAPO are jockeying in the talks to try to gain the upper hand in whatever elections are held before independence.

The key issues blocking an independence agreement are, in effect, whether South African or U.N. peacekeeping troops will have the main security role during the transition period and who controls the port of Walvis Bay.

The West said the gap between South Africa and SWAPO on how many of Pretoria's 20,000 troops remain has narrowed to 1,500 with south Africa wanting 3,000 and SWAPO agreeing with the western figure of 1,500. There is still the question of where the South African troops will be stationed when U.N. forces move in.

The West figures that the only way to handle the matter of Walvis Bay is to "finesse" it, a diplomatic way of saying South Africa's control of the port will be ignored for now. The general expectation is that time will take care of the problem, and the 400-square-mile area will eventually become part of Namibia which surrounds it.

In contrast, little more than a year ago Pretoria was still talking about a solution for Namibia along the lines of the internationally condemned homelands policy for blacks within South Africa.

So, why did South Africa Foreign Minister Pik Botha walk out of the talks early, with a sturm and drang reminiscent of the territory's beginnings as a German colony in the late 19th century?

One possibility is the SWAPO interpretation that South Africa never had any intention of reaching a deal with the West, could not afford to snub the foreign ministers and hoped that SWAPO would pull out. This would have given South Africa the opportunity to go ahead with its own "internal" solution, setting up a puppet government with local factions.

When this failed to materialize, Botha, a master at using the media, took the occasion, according to this theory, to make a television plea to Americans about how reasonable his country had been, an act which also played well to the home folks in South Africa.

A more commonly held theory is that South Africa is still wrestling with its decision, and Botha's outburst helps to protect it against right-wing extremist opposition on the domestic scene. The government may fear that it has moved too fast for its electorate, although it still wants to vacate the mineral-rich territory.

Perhaps it is acting somewhat like the nervous bridegroom before slipping on the ring.

The history of the German colony of South West Africa indicates that it would have been much easier for one side to get the better of the other in earlier times.

In one of the anachronisms of the colonialism, the British outfoxed the Germans, thereby permanently changing the map of Africa.

Germany was a latecomer to the colonial carving up of Africa, and in the 1890's Chancellor Leo, Count von Caprivi, decided the new German colony needed to stretch to the Zambezi River to give it a shipping outlet to the Indian Ocean.

The British were happy to oblige, ceding a narrow strip 280 miles long between their colonies, now known as Zambia and Botswana, in return for control of the Orange River at the southern border of Southwest Africa. In effect, the Caprivi Strip runs from nowhere to nowhere, since the count's knowledge of geography was lacking. He did not realize that a short distance downstream on his Zambezi River shipping route was the world's largest waterfall, Victoria Falls, 350 feet high and one mile wide.