Barcelona: The jewel in Spain's economy

Barcelona attack: Flowers, candles and tears
Barcelona attack: Flowers, candles and tears

Terrorists struck at the heart of Spain's economy on Thursday.

Barcelona is the country's second largest city after Madrid, and capital of Catalonia, Spain's biggest region in terms of economic output.

The region makes up 20% of Spain's GDP -- a fact touted by supporters of Catalonia's long-running bid for independence. (Another referendum on the issue could be held in October.)

Tourism is a big part of the story, but tech, shipping and manufacturing are also important.

Barcelona also punches above its weight internationally. A survey by EY found that the city is the fifth most attractive in Europe for international investors, behind London, Paris, Berlin and Amsterdam, but beating Frankfurt, Madrid and Dublin.

Spain terror attacks: Live updates

It alone attracted around 36% of all foreign investment in Spain in 2015, according to KPMG.

Here is what lies behind the city's success:

Tourism

Tourism plays a key role.

Barcelona is Spain's most popular destination, welcoming about 8 million international visitors a year who stay at least one night in the city. Many of them come to marvel at Antoni Gaudi's Sagrada Familia church.

Barcelona is also Europe's most popular cruise port, according to Euromonitor.

Transport

The city has been an important shipping center for centuries. Thanks to its strategic location on the Mediterranean coast near France, it acts as a natural gateway for traffic coming to Europe from North Africa and the Americas.

Shipping hit a record high in 2016 in terms of vessels, volume of cargo and number of passengers. It was up 18% year on year in the first half of this year, according to the port authorities.

Related: Airline stocks slump after Spain terror attacks

It's not just the sea: Barcelona's airport was Europe's seventh busiest in terms of passenger traffic in 2016, according to Airports Council International.

Technology

Barcelona boasts a thriving tech sector. It is home to a number of successful startups as well as research centers.

The sector makes up more than 7% of Barcelona's economy, according to the city council. That's roughly the same proportion as hotels and catering.

Cisco (CSCO) based its "Internet of Everything" innovation center in Barcelona. Candy Crush developer King, now owned by Activision Blizzard (ATVI), opened a large office in the city in 2012.

It's also home to the ALBA synchrotron, a particle accelerator facility, and the Barcelona Supercomputing Center.

Barcelona hosts the annual Mobile World Congress.

mobile world congress
Barcelona hosts the annual Mobile World Congress.

Industry & manufacturing

Barcelona and its wider metropolitan area is an important hub for manufacturing and industry.

Around 34% of all Spanish exports come from Catalonia. And official data show that a third of all Spanish exporters are based in Barcelona.

A third of all foreign companies that operate in Spain have chosen Barcelona as their base, according to the Catalan government. Volkswagen (VLKAY) and Nissan (NSANF) both have plants in the wider Barcelona region.

-- Alanna Petroff contributed reporting.

Personal Finance

LendingTree

CNNMoney Sponsors