Earlier in this thread, I had done East Africa. I will now do West Africa and Latin America. A big help is
OpenRailwayMap -- it's easy to see that many of Africa's railroad lines are inward from the coasts, though some places have good coastal lines, like Morocco - Algeria - Tunisia.
Gautrain is now open - essentially an electric commuter train. Johannesburg and Pretoria are about 36 mi / 59 km apart, as far apart as Washington DC and Baltimore MD, and closer than San Francisco and San Jose, both CA.
East Africa: Johannesburg, South Africa - 600 mi / 1000 km - Harare, ZImbabwe - 900 mi / 1500 km - Dar es Salaam, Tanzania - 400 mi / 700 km - Nairobi, Kenya - 700 mi / 1200 km - Addis Ababa, Ethiopia - 600 mi / 1000 km - Khartoum, Sudan - 1000 mi / 1600 km - Cairo, Egypt
West Africa: Cape Town, South Africa - 800 mi / 1300 km - Windhoek, Namibia - 1000 mi / 1600 km - Luanda, Angola - 300 mi / 500 km - Kinshasa, DRC - 500 mi / 800 km - Libreville, Gabon - 270 mi / 440 km - Yaoundé, Cameroon - 300 mi / 500 km - Port Harcourt, Nigeria - 300 mi / 500 km - Lagos, Nigeria - 250 mi / 400 km - Accra, Ghana - 250 mi / 400 km - Abidjan, Côte d'Ivoire - 500 mi / 800 km - Monrovia, Liberia - 300 mi / 500 km - Conakry, Guinea - 400 mi / 700 km - Dakar, Senegal - 250 mi / 400 km - Nouakchott, Mauritania - 1100 mi / 1700 km - Marrakesh, Morocco - 300 mi / 500 km - Tangier, Morocco, at the Strait of Gibraltar
I followed the coast rather than do an inland crossing of the Sahara Desert.
North Africa: Tangier, Morocco - 550 mi / 900 km - Algiers, Algeria - 400 mi / 600 km - Tunis, Tunisia - 400 mi / 700 km - Tripoli, Libya - 600 mi / 1000 km - Benghazi, Libya - 700 mi / 1100 km - Cairo, Egypt