It shows the greenhouse gas emissions by sectors of the economy. It includes 'negative' emissions, more properly called carbon removals, or carbon sequestration or simply carbon sinks. This is the sum of all the carbon dioxide taken out of the atmosphere by the sector of the economy called Land use, Land use change and Forestry.
Here is the chart.
This time I took a more traditional R approach to getting the the data into R from the Excel file CRF summary data.xlsx.
First, I used opened an X terminal window, and used the Linux wget command to download the spreadsheet "2017 CRF Summary data.xlsx" to a folder called "/nzghg2015".
I then used ssconvert (which is part of Gnumeric) to split the Excel (.xlsx) spreadsheet into comma-separated values files.
# open an XFCE terminal window, change directory, use the wget command to download "2017%20CRF%20Summary%20data.xlsx" to /nzghg2015 folder | |
$ cd /home/user/R/nzghg2015/ | |
$ wget http://www.mfe.govt.nz/sites/default/files/media/2017%20CRF%20Summary%20data.xlsx | |
# use Gnumeric via the command line to convert the .xlsx file and it's work sheets to separate .csv files with sheet number appended in place of "%n" and the most recent year of emissions (not the year of publication) | |
$ ssconvert -S --export-file-per-sheet '2017 CRF Summary data.xlsx' crf-data-2015-%n.csv | |
# list contents of folder to see the two new csv data files | |
$ ls -l | |
total 180 | |
-rw-r--r-- 1 user user 46759 May 23 10:49 2017 CRF Summary data.xlsx | |
-rw-r--r-- 1 user user 3749 Jun 14 14:26 crf-data-2015-0.csv | |
-rw-r--r-- 1 user user 5425 Jun 14 14:26 crf-data-2015-1.csv | |
-rw-r--r-- 1 user user 1 Jun 14 14:26 crf-data-2015-2.csv |
The Excel spreadsheet had 3 work sheets, 2 with data, and 1 that was empty. So there's now a .csv file for each sheet, even the empty sheet. And we read in the .csv file for emissions by sector.
# to read the .csv data file of GHG emissions by sector to the R workspace as a dataframe | |
gsector2015 <- read.csv("/home/user/R/nzghg2015/crf-data-2015-0.csv", skip=2, header=TRUE, sep=",", colClasses ="numeric", nrows=27, na.strings=NA, dec=".", strip.white=TRUE) | |
# examine the dataframe | |
str(gsector2015) | |
data.frame: 26 obs. of 8 variables: | |
$ Year : num 1990 1991 1992 1993 1994 ... | |
$ Energy. : num 23748 24140 26041 25475 25762 ... | |
$ Industrial.processes.and.product.use..IPPU. : num 3584 3733 3378 3218 3098 ... | |
$ Agriculture. : num 33123 33471 33149 33364 34340 ... | |
$ Land.use..land.use.change.and.forestry..LULUCF.: num -30122 -32130 -31620 -32263 -32317 ... | |
$ Waste. : num 4118 4215 4301 4388 4323 ... | |
$ Net.emissions..including.LULUCF. : num 34451 33428 35250 34181 35206 ... | |
$ Gross.emissions..without.LULUCF. : num 64574 65559 66870 66444 67523 ... | |
# Simplify the column names (vector names) | |
colnames(gsector2015) <- c("Year", "Energy", "Industrial", "Agriculture", "LULUCF", "Waste", "Netemissions", "Grossemissions") |
The final step is to make the chart.
png("NZ-ghgsector-2015-560.png", bg="white", width=560, height=420,pointsize = 14) | |
par(mar=c(2.7,2.7,1,1)+0.1) | |
plot(gsector2015[["Year"]],gsector2015[["Agriculture"]]/1000,ylim=c(-42,60), xlim=c(1989,2015),tck=0.01,axes=FALSE,ann=FALSE, type="n",las=1) | |
axis(side=1, tck=0.01, las=0, lwd = 1, at = c(1990:2015), labels = c(1990:2015), tick = TRUE) | |
axis(side=2, tck=0.01, las=2, line = NA,lwd = 1, at = c(-30,-20,-10,0,10,20,30,40), labels = c(-30,-20,-10,0,10,20,30,40),tick = TRUE) | |
axis(side=3, tck=0.01, at = c(1990:2015), labels = FALSE, tick = TRUE) | |
axis(side=4, tck=0.01, at = c(-30,-20,-10,0,10,20,30,40), labels = FALSE, tick = TRUE) | |
box(lwd=1) | |
lines(gsector2015[["Year"]],gsector2015[["Agriculture"]]/1000,col="#1b9e77",lwd=1) | |
points(gsector2015[["Year"]],gsector2015[["Agriculture"]]/1000,col="#1b9e77",cex=1,pch=7) | |
lines(gsector2015[["Year"]],gsector2015[["Energy"]]/1000,col="#d95f02",lwd=1) | |
points(gsector2015[["Year"]],gsector2015[["Energy"]]/1000,col="#d95f02",cex=1,pch=8) | |
lines(gsector2015[["Year"]],gsector2015[["Industrial"]]/1000,col="#7570b3",lwd=1) | |
points(gsector2015[["Year"]],gsector2015[["Industrial"]]/1000,col="#7570b3",cex=1,pch=9) | |
lines(gsector2015[["Year"]],gsector2015[["Waste"]]/1000,col="#e7298a",lwd=1) | |
points(gsector2015[["Year"]],gsector2015[["Waste"]]/1000,col="#e7298a",cex=1,pch=10) | |
lines(gsector2015[["Year"]],gsector2015[["LULUCF"]]/1000,col="#66a61e",lwd=1) | |
points(gsector2015[["Year"]],gsector2015[["LULUCF"]]/1000,col="#66a61e",cex=1,pch=11) | |
abline(h=0,col=1,lwd=1,lty=1) | |
text(1990,40,adj=0,"Agriculture + 16%",col=1,cex=1) | |
text(2015,26,adj=1,"Energy + 37%",col=1,cex=1) | |
text(1990,10,adj=0,"Waste - 3%",col=1,cex=1) | |
text(2015,10,adj=1,"Industry + 47%",col=1,cex=1) | |
text(2015,-18,adj=1,"Land Use & Forestry Removals -21%",col=1,cex=1) | |
mtext(side=1,line=-1.5,cex=0.8,"Data: New Zealand’s Greenhouse Gas Inventory 1990 – 2015, \nMfE 2017 Report ME 1309 http://www.mfe.govt.nz/node/23304/") | |
mtext(side=3,cex=1.5, line=-4,expression(paste("New Zealand Greenhouse Gas \nEmissions by Sector 1990 to 2015")) ) | |
mtext(side=2,cex=0.9, line=-1.5,expression(paste("million tonnes C", O[2], "-e"))) | |
mtext(side=4,cex=0.75, line=0.05,R.version.string) | |
dev.off() |