FOR those who believe that migration can, if managed properly, make a country materially and culturally richer, recent developments in European politics have been worrying. In many countries anti-migrant sentiment—either directed towards those from outside the European Union or against other, often poorer, EU members—has penetrated from the fringes of politics into the mainstream. Britons disgruntled with Eastern Europeans exercising their right to live and work there voted for Brexit in 2016. Marine Le Pen of France’s far-right Front National (FN) made it into the runoff against Emmanuel Macron in the 2017 presidential election partly by campaigning heavily in areas such as Calais, which were particularly affected by the refugee crisis. In Germany the Alternative fur Deutschland (AfD), an anti-immigrant party, entered parliament for the first time in 2017, winning 92 seats out of 709.

Parties such as the FN and the AfD tend to portray immigrants as a threat to jobs, domestic security and cultural harmony. But the results of a recent Eurobarometer survey suggests that in practice, Europeans’ views of migrants are still relatively positive. This is particularly true if they live in a country which actually hosts significant numbers of immigrants.

Fully 83% of Spaniards and 81% of Swedes say that they would feel comfortable having an immigrant as a social relation. Swedes are also particularly happy to have immigrants as friends, with 87% feeling totally comfortable being friendly with one, and only 9% somewhat comfortable. They also lead the way across the EU in being happy with having immigrants as neighbours, colleagues and managers. Not surprisingly, Sweden welcomed the highest number of refugees per person during the refugee crisis in 2015. Though there have been some tensions since then—the Sweden Democrats, an anti-immigrant party, surged in the polls, and Sweden has tightened its border regime—the Eurobarometer results suggest that Swedes remain welcoming to their new neighbours.

Britons are also remarkably sanguine about knowing immigrants. They are the most likely in the EU to be happy to have an immigrant as a doctor: possibly testament to the fact that, according to statistics from 2014, more than a quarter of doctors in the National Health Service are foreign nationals. But Britons are also just behind Swedes and Norwegians in saying that they would be happy to have an immigrant as a neighbour, colleague, friend or family relation.

This highlights that immigration to Britain has been a broadly positive story over time. Though the country has not always treated them well, generations of migrants from the Caribbean, Uganda, and elsewhere have been coming to live and work in Britain for decades. European migrants, many of whom arrived over the past couple of decades, are more likely to pay taxes than to receive benefits. They are also far younger than the Britons who move abroad.

Two European countries stand out for their particular dislike of immigrants: Hungary and Bulgaria. Respondents from these countries were the least likely to be happy to know immigrants in any circumstances; over half would feel uncomfortable with any relationship to an immigrant at all. Both countries have very few immigrants, however: the percentage of foreign-born population in 2017 was just 2% for Bulgaria and 5% in Hungary, in contrast to 18% in Sweden.

Though the survey is a snapshot, it is a revealing one. It suggests that proximity to immigrants correlates with pro-migrant sentiment, rather than the opposite. In countries where there are fewer people that don't look like you, or sound like you, it's easier to whip up anti-immigrant sentiment against an imaginary bogeyman. The AfD did particularly well in the former East Germany, which has the smallest proportion of refugees and immigrants in the country. Viktor Orban, Hungary’s populist prime minister, can make immigrants into scapegoats because so few exist in his country to refute him.

The survey results also suggest that younger people, the more educated, and those living in cities are particularly likely to feel positive towards migrants. (Perhaps not surprisingly, immigrants tend to cluster in cities, too.) It seems that when it comes to migration, the political fault lines in Europe increasingly run between the young and the old, and between urban and rural types.