Land of the Beer, Home of the Grape.

My recent posts featured a series of topics around nuclear energy [1, 2, 3]. This was not intended from the beginning on, but rather evolved by wiki-walking from one idea to another. With this post, I start a new series by intention, and it will be about… one of my favourite activities. But I won’t tell you right now, you’ll find out. I’d rather like to tell another story. Some time ago a friend of mine forgot a beer at my place, it was one of this kind. I usually avoid brands like these, because back in the days it used to smell like the parts of zoos where too many animals share too small cages. Anyway, I was desperate and gave it a shot. You won’t believe it, the zoo was gone and replaced by a pleasing smell of nothingness. The one you will find in 75 % of German large-scale brewed beers. Here in Germany beer is (still) the number one alcoholic beverage, although the big breweries always complain about dropping sales. For my part, I know exactly why. But whats the situation in Europe in general? Here are some numbers on the drinking habits of our neighbors (click to enlarge).

Continue reading Land of the Beer, Home of the Grape.

Radioactive, man 3: Japan backs off

Now it happened. The unimaginable came true. Japan has just announced to exit atomic energy until 2040. Of course, Japan is not exactly Europe, but this is interesting in two ways. First, I coincidentally wrote about the rule role of nuclear energy in Europe and the accidents taking place in the past 60 years of civilian nuclear energy.
And second, because the nuclear superpower Japan performed a U-turn in its energy policy, joining an illustrous club of nations, which decided to phase out or refuse nuclear energy in general. Let’s take a closer look at these countries on a map (this one’s from wikipedia):

Continue reading Radioactive, man 3: Japan backs off

Radioactive, man 2: Accidents

In my last post I plotted a map with the major nuclear power plants and the nuclear share of total energy production per country. The cherry-pickers of you know, that energy is not really “produced” but only transformed from one state (heat) into another (electrical current), according to the first law of thermodynamics. Thermodynamics is boring, that’s why we will create another map. This time, it’s about the consequences of nuclear energy usage. More precisely, the guardian has collected some data on 33 accidents in power plants since 1952. The severity of these accidents is rated by the IAEA using the so-called INES (International Nuclear Events Scale) ranging from 1 to 7.

Nuclear accidents since 1952 rated by IAEA’s INES scale. Source: IAEA, Guardian.

Continue reading Radioactive, man 2: Accidents

Radioactive, man!

Today we will approach a literally very hot topic. The use of nuclear power to satisfy our huge energy demand is a controversy ever since, but it has recently gained momentum due to the Fukushima disaster (pics, maps). But this is just the newest in a long line of incidents since the very first commercial reactor was connected to the power grid in 1954 (Obninsk in the former Soviet Union, with a capacity of 6 MW). Remember Three Mile Island (1979), Chernobyl (1986) and now Fukushima, where it’s still hard to measure the consequences due to the sneaky nature of nuclear radiation.

But the risk of failure of power plants is just one aspect of this energy branch, and in my opinion it’s the most negligible. Of course it is impossible to build 100% safe nuclear power plants, but you can minimize the risk by using inherently safe reactor types (yes, we have those) like the Pebble Bed Reactor, not building plants in earthquake active areas (Fukushima…) or doing strange overheating experiments (Chernobyl…). The question is rather if nuclear power is a “clean” energy source and should be part of the energy mix of the future: I would say no. Power plants are not producing energy out of nothing, they must be fed with uranium (characteristics and mining), which is a scarce resource and may run out just like oil, gas and coal. But before I answer the question, if we can live with renewables as our sole energy source, let’s take a look on the situation in Europe.

Nuclear energy in Europe, with country colors as nuclear energy share on total energy and symbols representing nuclear power plants with more than one Gigawatt. Source: IAEA, wikipedia.

Continue reading Radioactive, man!

Where your iPads arrive (and everything else)…

My recent visit to Hamburg inspired me to do some research on ports in europe. My thoughts went in the direction of something like the biggest ports or the biggest trade volume per port city. I was rather convinced it would take a lot of effort to find some data, but this time, again, wikipedia served me well. There’s actually a simple list about the busiest ports in Europe! You can choose between total transshipment in tons or container units (the so called TEUs, meaning “Twenty-foot equivalent unit” and referring to its length). I opted for the first to get a more general impression. The next thing I needed was the coordinates of each port which I retrieved from wikepidia in a painstaking copy and paste marathon. If anybody knows how to get coordinates from cities automatically, give me a hint. Here comes the map.

Busiest harbours of Europe in million tons transshipment

As you can see, this race is clearly won by the BeNeLux countries, more specifically Rotterdam and Antwerpen, the biggest ports in Europe, followed by Hamburg. This data is from 2010, and I read somewhere that Hamburg has overtaken Antwerpen lately. Rotterdam seems not to be endangered, anyway. But these things might change quickly, depending on the economical situation. However, the odds are that your iWhatever will first see the cranes of Rotterdam when entering Europe…

Here comes the code for the  map. Note that I also tried the bubble() function from the sp-package for the bubble plot, but found the conventional plot more flexible in terms of presentation. If you want it quick and high htroughput, the bubble() function may be your friend.

# load europe map
europe <- readShapeSpatial(fn="europe", proj4string=CRS("+proj=longlat"))
europe <- spTransform(europe,  CRS("+init=epsg:3035"))

# import data of busiest harbours and project coords
harbours <- read.csv("harbours.csv")
coordinates(harbours) <- harbours[c("N","E")]
proj4string(harbours) <- CRS("+proj=longlat")
harbours <- spTransform(harbours,  CRS("+init=epsg:3035"))

# plot a bubble map (package:sp)
bubble(harbours, "Thousands.of.tons")

# plot conventional map
plot(europe, xlim=c(2.5e+06, 6.5e+06), ylim=c(1.45e+06, 5.4e+06), border="white", col="lightgrey", na.rm=TRUE)

# add bubbles
colramp <- colorRampPalette(c("#4876FF","#FF0000"))(100)
labels <- toupper(substring(harbours@data$Port,1,3))
trade <- harbours@data[["Thousands.of.tons"]]/429926

points(coordinates(harbours)[,1], coordinates(harbours)[,2], pch=19, cex=trade*15, col=colramp[trade*100])
text(coordinates(harbours)[,1], coordinates(harbours)[,2]-2e5, labels=labels, cex=0.75)
# add legend
legend("topleft", legend=paste(labels,
    round(harbours@data[["Thousands.of.tons"]]/1000), sep="\t"), pch=19,
    col=colramp[trade*100], cex=0.8, bty="n")

How green is Europe?

As I am working for a scientific institution called Helmholtz Centre for Environmental Research, I am often confronted with environmental topics. Although my home country Germany performs well in “green” technologies and the like, you don’t see THAT much green area when you look out of the window. With the exception of inner city parks suited for daily barbecues… When travelling in Germany you rather get the impression, that the remaining “wild” areas are dispersed like islands within cultivated area. When I was in Finland, it seemed the other way around. But these are just my personal impressions, let’s see if we can find some data.

My starting hypothesis is, that e.g. the scandinavian countries have a much higher percentage of areas with some official protection status, like national parks or reserves. As a starting point, we can use a wiki list of all national parks by continent and save it as *.csv table. Always worth a try is also Eurostat, the european statistics agency, where you can find data on marine and terrestrial protected areas under the “environment” section. We can plot a map of europe as described here and color-code the total protected area in green (% of total country area). And we can display the three protected area indices (marine, terrestrial, national parks) separately by overlaying mini barplots for selected countries. This is what it looks like in the end:


Quite surprising. Neither Finland nor Sweden are the most “green” country in terms of protected area. Actually, Slovenia, Spain, Denmark and the Netherlands have a higher proportion. But we easily see that the good ranking of the two naval powers Denmark and the Netherlands is due to marine areas. Remember for instance, that Greenland (and the surrounding waters?) politically belongs to Denmark.

Here comes the code for the  map:

# import data of national parks and protected areas
pa <- read.csv("protected_areas.csv")
np <- read.csv("nationalparks.csv")

# merge data.frames by country names and sort
pa$Country <- toupper(pa$Country)
np$Country <- toupper(np$Country)
europe@data <- merge(europe@data, pa, by.x="NAME", by.y="Country", all.x=TRUE, all.y=FALSE, sort=FALSE)
europe@data <- merge(europe@data, np, by.x="NAME", by.y="Country", all.x=TRUE, all.y=FALSE, sort=FALSE)
europe@data <- europe@data[order(as.numeric(as.character( europe@data$SP_ID))), ]

# calculate percent areas
europe@data[c("%_ta","%_ma","%_pa")] <- europe@data[c(8,9,12)]/europe@data$AREA*100

# plot the map
colors <- colorRampPalette(c("darkkhaki", "darkgreen"))(50)
plot(europe, xlim=c(2.5e+06, 6.5e+06), ylim=c(1.45e+06, 5.4e+06), border="white",
col=colors[1+rowSums(europe@data[c("%_ta","%_ma","%_pa")], na.rm=TRUE)])

legend("topleft", bty="n", title="% TOTAL PROTECTED AREA", legend=c("NA", seq(5,40,5)), pch=15, pt.cex=3, col=colors[c(1,seq(5,40,5))])

The country barplots are done with a dirty for-loop and usage of the par(“plt”) command, which restricts plotting of new objects to a certain range of the figure (default=c(0,1,0,1)). This range is set as the center coordinates of the country +/- something. This is certainly not an elegant way, but on the other hand it allows to overlay any (base) graphics you like.

# add mini barplots for selected countries
legend("topright", bty="n", title="% PROTECTED AREA", legend=c("terrestrial","marine","national park"),
fill=c("orange4","cornflowerblue", "chartreuse4"))

pos <- as.data.frame(cnvrt.coords(coordinates(europe)[,1], coordinates(europe)[,2], "usr")[["plt"]])

for (i in which(complete.cases(europe@data))){
par(plt=c(pos[i,1]-0.025,pos[i,1]+0.025,pos[i,2], pos[i,2]+0.1), new=TRUE)
barplot(as.numeric(europe@data[i, c("%_ta", "%_ma", "%_pa")]), axes=FALSE, ylim=c(0,50),
space=0, col=c("orange4","cornflowerblue", "chartreuse4"))
}

Go for gold

The major players of the olympic games are usually the countries with the biggest population, at least when it comes to counting medals. Let’s take a look how the european countries performed. For that, we will need a map and some data to project on it. I usually use the free statistics “language” R which is very versatile and gained a lot of popularity in the last years. Among the wealth of geographic packages, I chose the following:

library(maptools)
library(rgdal)

Next, we need a shapefile, which stores coordinate data and other annotation, in other words, a map. You can find free world map data for instance here or here. We can import it in R by using the function readSpatialShape and discard countries we don’t need by simple subsetting. The most difficult part was to find a good projection, but luckily I stumbled over a hint from Roger Bivand. Projection means, the convex surface of the globe must somehow be stretched on a 2D plain (the spTransform function does that for us). The actual plotting of the map is simple and I overlaid the detailed medal count per country by adding legends. Not elegant, but here is what I came up with.

So far, no big surprises. Russia is the winner, the UK had home advantage, but…oh: Austria didn’t win a single medal! I can hear the heads rolling. However, big countries usually have more inhabitants, more athletes and more money, that’s why this map is not really informative. But we can correct this bias by calculating the medals per million inhabitants instead of absolute numbers. And we can compare this to the amount of money invested in sports by the country per capita (source: EU study).

The true winners in medals are neither France nor Germany, but smaller countries like Denmark, Slovenia and the baltics. Most amazingly, these are countries that do not fund sports very well. On the other hand, eastern and southern european countries invest little and receive little.
Here’s the code:

# import europe map and apply projection
europe <- readShapeSpatial(fn="europe.sf/europe", proj4string=CRS("+proj=longlat"))
europe <- spTransform(europe,  CRS("+init=epsg:3035"))

# import result table of London 2012 and merge with map annotation
medals <- read.csv("London2012medals.csv")
medals$Country <- toupper(medals$Country)
europe@data <- merge(europe@data, medals, by.x="NAME", by.y="Country", all.x=TRUE, all.y=FALSE, sort=FALSE)
europe@data <- europe@data[order(as.numeric(as.character(europe@data$SP_ID))),]
europe@data <- cbind(europe@data, x=coordinates(europe)[,1], y=coordinates(europe)[,2])

# plot europe map
colors <- colorRampPalette(c("chocolate4", "yellow"))(100)
plot(europe, xlim=c(2.5e+06, 6.5e+06), ylim=c(1.45e+06, 5.4e+06), border="white", col=replace(colors[europe@data$Total], is.na(europe@data$Total), "grey"))
legend("topleft", bty="n", title="Total medal count", legend=seq(0,100,10), pch=15, pt.cex=3, col=c("grey", colors[seq(0,100,10)]))

#plot medal counts for each country
for (i in which(!is.na(europe@data[["Rank.by.Gold"]]))) {
legend(europe@data[i,"x"], europe@data[i,"y"], bg="#FFFFFF90",
box.col="grey", pch=19, pt.cex=1.5, cex=0.7, xjust=0.5, yjust=0.75,
col=c("darkgoldenrod1", "peachpuff4", "chocolate4"), legend=europe@data[i,8:10])}

# plot a bubble map
plot(europe, xlim=c(2.5e+06, 6.5e+06), ylim=c(1.45e+06, 5.4e+06), border="white", col="grey")
points(europe@data$x, europe@data$y, pch=19, cex=funding$medals.per.million*5, col="#FF7F24BB")
text(europe@data$x, europe@data$y, labels=round(funding$medals.per.million, digits=1), col="white", cex=0.7)

And the winner is…

…the country that won the most medals in the London 2012 Olympic games. At first glance we would easily choose the United states or China. But this blog will focus on the land mass called Europe and the countries it accommodates. But first things first. The idea to get involved a little bit more into “european” topics came out during my abroad stay in Finland 2009 where I met so many interesting fellow students from all over Europe. The feeling to be part of something bigger than our nation was in the air, but nowadays, there’s again much controversy about sense and non-sense of a unified Europe. With this blog I will try to shed some light on european affairs using mainly numbers and figures. My second pet subject is statistics, data visualization and free software: a combination that matches well.

Since the Olympic games 2012 just finished, we can now take a european point of view towards medals and more.