Giovan Battista Magnaghi was born in Lomello, near Pavia, on March 21st 1839. The son of a landowner, he moved to Genoa with his family  when he was a little boy  and discovered the sea.  In 1851, when he was only twelve years old, he entered the Navy School in Genoa, thanks to a rather important family friend – Camillo Benso, count of Cavour.
In 1855 he completed the academy with the rank of ensign and fought in the siege of Gaeta (1860) and the battle of Lissa (1866). He was awarded the Gran Cross of the Military Order of Savoy. In the same years, the Ministry of the Navy was working at the creation of a hydrographic service similar to those that were being created in other countries, in order to improve survey and chart coverage of Italian waters. At the time, most existing charts of the Mediterranean Sea were the result of the work of French and English cartographers.
Magnaghi was given the task to study and plan an Italian hydrographic office and toured around the corresponding offices in Europe to see how they were organized and what instruments and equipment they were using.
In 1872 the Istituto Idrografico della Regia Marina was founded and housed in the Fortress of San Giorgio in Genoa. Commander Magnaghi was its first director. Magnaghi devoted himself to the Institute, studying oceanography and developing new and more accurate instrumentation. He devised for example the reversing bottle, for deep water sampling, and a frame for reversal thermometers; he also improved Amici’s reflecting circle, the liquid-filled magnetic compass, the Thomson’s depth sounder and the current meter, fundamental for both hydrographers and oceanographers. Magnaghi published a seminal essay on reflecting instruments, the sun azimuth tables and nautical tables, which are crucial for all mariners. Under Magnaghi, the Italian hydrographic service charted three quarters of the national coasts, producing over 100 nautical charts, port plans and coastal views, the result of extensive surveys.

Magnaghi organized training courses for hydrographers and for engravers and cartographers.

He died in Rome on June 21st  1902.