Created
April 10, 2015 17:02
-
-
Save dyorama/a7423ffe35358d9555ac to your computer and use it in GitHub Desktop.
Module 3, exercice 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
country | forest1992Km2 | forest2002Km2 | forest2012Km2 | forestLossorWin19922012 | forestLossorWin20022012 | forest1992% | forest2002% | forest2012% | |
---|---|---|---|---|---|---|---|---|---|
Latin America and Caribbean | 10302831 | 9815764 | 9394936 | -907896 | -420828 | 51 | 49 | 47 | |
Russian Federation | 8090136 | 8090771 | 8092100 | 1964 | 1329 | 49 | 49 | 49 | |
Brazil | 5690598 | 5397634 | 5151332 | -539266 | -246302 | 68 | 64 | 62 | |
Low income | 4652830 | 4368853 | 4092572 | -560258 | -276281 | 31 | 29 | 28 | |
Canada | 3101340 | 3101340 | 3101340 | 0 | 0 | 34 | 34 | 34 | |
United States | 2971070 | 3009602 | 3047876 | 76806 | 38274 | 32 | 33 | 33 | |
China | 1611126 | 1834179 | 2123873 | 512747 | 289694 | 17 | 20 | 23 | |
European Union | 1423830 | 1546458 | 1597946 | 174116 | 51487 | 35 | 36 | 38 | |
Congo Democratic Republic | 1597402 | 1566262 | 1535122 | -62280 | -31140 | 70 | 69 | 68 | |
Australia | 1545840 | 1545200 | 1474520 | -71320 | -70680 | 20 | 20 | 19 | |
Indonesia | 1147178 | 987882 | 930620 | -216558 | -57262 | 63 | 55 | 51 | |
Small states | 900827 | 879302 | 862331 | -38496 | -16971 | 39 | 38 | 37 | |
South Asia | 794999 | 801411 | 818501 | 23502 | 17090 | 17 | 17 | 17 | |
India | 642292 | 663176 | 687240 | 44948 | 24064 | 22 | 22 | 23 | |
Peru | 699674 | 690246 | 676920 | -22754 | -13326 | 55 | 54 | 53 | |
Mexico | 695830 | 662818 | 644916 | -50914 | -17902 | 36 | 34 | 33 | |
Colombia | 623170 | 613070 | 602970 | -20200 | -10100 | 56 | 55 | 54 | |
Angola | 607264 | 594784 | 582304 | -24960 | -12480 | 49 | 48 | 47 | |
Bolivia | 622542 | 595482 | 565808 | -56734 | -29674 | 57 | 55 | 52 | |
Zambia | 524668 | 508008 | 491348 | -33320 | -16660 | 71 | 68 | 66 | |
Venezuela | 514510 | 485758 | 456998 | -57512 | -28760 | 58 | 55 | 52 | |
Mozambique | 429400 | 407444 | 385992 | -43408 | -21452 | 55 | 52 | 49 | |
Tanzania | 406884 | 366552 | 326212 | -80672 | -40340 | 46 | 41 | 37 | |
Myanmar | 383480 | 342492 | 311538 | -71942 | -30954 | 59 | 52 | 48 | |
Argentina | 342066 | 313562 | 289204 | -52862 | -24358 | 12 | 11 | 11 | |
Papua New Guinea | 312450 | 298546 | 284416 | -28034 | -14130 | 69 | 66 | 63 | |
Sweden | 273026 | 277146 | 282030 | 9004 | 4884 | 67 | 68 | 69 | |
Japan | 249352 | 248996 | 249966 | 614 | 970 | 68 | 68 | 69 | |
Central African Republic | 231430 | 228438 | 225450 | -5980 | -2988 | 37 | 37 | 36 | |
Congo Republic | 226923 | 225223 | 223870 | -3053 | -1353 | 66 | 66 | 66 | |
Finland | 220030 | 223382 | 221570 | 1540 | -1812 | 72 | 73 | 73 | |
Gabon | 220000 | 220000 | 220000 | 0 | 0 | 85 | 85 | 85 | |
Malaysia | 222190 | 213106 | 202824 | -19366 | -10282 | 68 | 65 | 62 | |
Cameroon | 238760 | 216760 | 194760 | -44000 | -22000 | 51 | 46 | 41 | |
Thailand | 194400 | 189616 | 190016 | -4384 | 400 | 38 | 37 | 37 | |
Spain | 144523 | 171100 | 185253 | 40730 | 14153 | 29 | 34 | 37 | |
Paraguay | 207992 | 190108 | 172248 | -35744 | -17860 | 52 | 48 | 43 | |
Chile | 153772 | 159176 | 163062 | 9290 | 3886 | 21 | 21 | 22 | |
France | 147002 | 154974 | 160500 | 13498 | 5526 | 27 | 28 | 29 | |
Lao PDR | 171576 | 163760 | 155946 | -15630 | -7814 | 74 | 71 | 68 | |
Guyana | 152050 | 152050 | 152050 | 0 | 0 | 77 | 77 | 77 | |
Zimbabwe | 215100 | 182400 | 149700 | -65400 | -32700 | 56 | 47 | 39 | |
Suriname | 147760 | 147760 | 147508 | -252 | -252 | 95 | 95 | 95 | |
Vietnam | 98354 | 122658 | 140850 | 42496 | 18192 | 30 | 39 | 45 | |
Madagascar | 135780 | 130084 | 124390 | -11390 | -5694 | 23 | 22 | 21 | |
Mali | 139138 | 131226 | 123320 | -15818 | -7906 | 11 | 11 | 10 | |
Ethiopia | 164442 | 134230 | 120144 | -44298 | -14086 | 15 | 13 | 12 | |
Turkey | 97732 | 103836 | 115716 | 17984 | 11880 | 13 | 13 | 15 | |
Chad | 129514 | 121586 | 113666 | -15848 | -7920 | 10 | 10 | 9 | |
Botswana | 134814 | 122982 | 111142 | -23672 | -11840 | 24 | 22 | 20 | |
Germany | 108080 | 110760 | 110760 | 2680 | 0 | 31 | 32 | 32 | |
Iran Islamic Republic | 110750 | 110750 | 110750 | 0 | 0 | 7 | 7 | 7 | |
Mongolia | 123722 | 115534 | 107340 | -16382 | -8194 | 8 | 7 | 7 | |
Cote d'Ivoire | 102432 | 103588 | 104022 | 1590 | 434 | 32 | 33 | 33 | |
Norway | 91642 | 94538 | 102178 | 10536 | 7640 | 25 | 31 | 28 | |
Cambodia | 126644 | 112200 | 98392 | -28252 | -13808 | 72 | 64 | 56 | |
Ukraine | 93212 | 95360 | 97570 | 4358 | 2210 | 16 | 16 | 17 | |
Ecuador | 134218 | 114458 | 94698 | -39520 | -19760 | 48 | 46 | 38 | |
Poland | 89166 | 91154 | 93918 | 4752 | 2764 | 29 | 30 | 31 | |
Italy | 77458 | 85250 | 93050 | 15592 | 7800 | 26 | 29 | 32 | |
South Africa | 92410 | 92410 | 92410 | 0 | 0 | 8 | 8 | 8 | |
Belarus | 78786 | 83382 | 87076 | 8290 | 3694 | 39 | 41 | 43 | |
Senegal | 92582 | 88082 | 83930 | -8652 | -4152 | 48 | 46 | 44 | |
New Zealand | 78292 | 82840 | 82522 | 4230 | -318 | 30 | 31 | 31 | |
Nigeria | 164146 | 123178 | 82218 | -81928 | -40960 | 18 | 14 | 9 | |
Philippines | 66794 | 72266 | 77746 | 10952 | 5480 | 22 | 24 | 26 | |
Namibia | 86160 | 78836 | 71416 | -14744 | -7420 | 10 | 10 | 9 | |
Romania | 63700 | 63760 | 66458 | 2758 | 2698 | 28 | 28 | 29 | |
Somalia | 81286 | 73614 | 65934 | -15352 | -7680 | 13 | 12 | 11 | |
Guinea | 71920 | 68320 | 64720 | -7200 | -3600 | 29 | 28 | 26 | |
Korea Republic | 63536 | 62748 | 62088 | -1448 | -660 | 66 | 65 | 64 | |
Burkina Faso | 67272 | 61284 | 55290 | -11982 | -5994 | 25 | 22 | 20 | |
Korea Democratic. Republic | 79474 | 66794 | 54128 | -25346 | -12666 | 66 | 55 | 45 | |
Morocco | 50426 | 50426 | 51510 | 1084 | 1084 | 11 | 11 | 12 | |
Honduras | 77872 | 61520 | 49520 | -28352 | -12000 | 70 | 55 | 44 | |
Ghana | 71772 | 58632 | 47092 | -24680 | -11540 | 32 | 26 | 21 | |
Benin | 56210 | 49610 | 44610 | -11600 | -5000 | 50 | 44 | 40 | |
Liberia | 48690 | 45690 | 42690 | -6000 | -3000 | 51 | 47 | 44 | |
Turkmenistan | 41270 | 41270 | 41270 | 0 | 0 | 9 | 9 | 9 | |
Bulgaria | 33366 | 34854 | 40374 | 7008 | 5520 | 30 | 32 | 37 | |
Pacific island small states | 39863 | 39940 | 39729 | -134 | -211 | 62 | 62 | 62 | |
Greece | 33594 | 36614 | 39634 | 6040 | 3020 | 26 | 28 | 31 | |
Austria | 37884 | 38476 | 38970 | 1086 | 494 | 46 | 47 | 47 | |
Nepal | 46336 | 37944 | 36360 | -9976 | -1584 | 32 | 26 | 25 | |
Guatemala | 46400 | 41000 | 35446 | -10954 | -5554 | 43 | 38 | 33 | |
Portugal | 33456 | 34268 | 34636 | 1180 | 368 | 37 | 37 | 38 | |
Kenya | 36828 | 35580 | 34450 | -2378 | -1130 | 6 | 6 | 6 | |
Latvia | 31866 | 32634 | 33768 | 1902 | 1134 | 51 | 52 | 54 | |
Kazakhstan | 34106 | 33538 | 32978 | -1128 | -560 | 1 | 1 | 1 | |
Bhutan | 30562 | 31626 | 32706 | 2144 | 1080 | 65 | 79 | 86 | |
Uzbekistan | 30784 | 32452 | 32677 | 1893 | 225 | 7 | 8 | 8 | |
Panama | 37074 | 33454 | 32274 | -4800 | -1180 | 50 | 45 | 43 | |
Malawi | 38302 | 35010 | 31710 | -6592 | -3300 | 41 | 37 | 34 | |
Nicaragua | 43740 | 36740 | 29740 | -14000 | -7000 | 36 | 31 | 25 | |
Cuba | 21334 | 25398 | 29392 | 8058 | 3994 | 20 | 24 | 28 | |
United Kingdom | 26474 | 28138 | 28954 | 2480 | 816 | 11 | 12 | 12 | |
Uganda | 45746 | 36930 | 28116 | -17630 | -8814 | 23 | 18 | 14 | |
Serbia | 28078 | 28078 | 28078 | 32 | |||||
Georgia | 27770 | 27627 | 27372 | -398 | -255 | 40 | 40 | 39 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Forest area in 2012 in km2</title> | |
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script> | |
<style type="text/css"> | |
body { | |
background-color: white; | |
} | |
svg { | |
background-color: white; | |
} | |
rect { | |
fill: green; | |
} | |
</style> | |
</head> | |
<body> | |
<h1> Top 100 countries by woodland </h1> | |
<p>Forest area per country (km2, 2012)</p> | |
<!-- BEGIN CHART --> | |
<script type="text/javascript"> | |
// make svg element to hold the chart | |
var svg = d3.select("body") | |
.append("svg") | |
.attr("width", 1200) | |
.attr("height", 1150); | |
// load CSV data | |
d3.csv("forestdata.csv", function(data) { | |
// sort bars in descending order | |
data.sort(function(a, b) { | |
return d3.descending(+a.forest2012Km2, +b.forest2012Km2); | |
//If your numeric values aren't sorting properly, | |
//try commenting out the line above, and instead using: | |
// | |
//return d3.descending(+a.lifeSatisfaction, +b.lifeSatisfaction); | |
// | |
//Data coming in from the CSV is saved as strings (text), | |
//so the + signs here force JavaScript to treat those | |
//strings instead as numeric values, thereby fixing the | |
//sort order (hopefully!). | |
}); | |
// create rectangles for each data value | |
var rects = svg.selectAll("rect") | |
.data(data) | |
.enter() | |
.append("rect"); | |
// set size for the bars. start each bar at Opx acriss to leave room for labels, and move down 12px for the next bar. | |
rects.attr("x", 0) | |
.attr("y", function(d, i) { | |
return i * 12; | |
}) | |
// divide the data value by 10,000 to fit the scale | |
.attr("width", function(d) { | |
return d.forest2012Km2 / 10000; | |
}) | |
// allot 10px for each bar and compose tooltip | |
.attr("height", 10) | |
.attr(fill="green") | |
.append("title") | |
.text(function(d) { | |
return d.country + "'s forest area is " + d.forest2012Km2 + " km2" ; | |
}) | |
// add axis labels on left, 15px apart, starting at 9px down and 140px across | |
svg.selectAll("text") | |
.data(data) | |
.enter() | |
.append("text") | |
.text(function(d){ | |
return d.country; | |
}) | |
.attr("x", 0) | |
.attr("y", function(d, i){ | |
return i * 15 + 9; | |
}) | |
// type attributes for the labels | |
.attr({ | |
"fill": "black", | |
"font-family": "sans-serif", | |
"font-size": "15px", | |
"text-anchor": "end" | |
}) | |
}); | |
</script> | |
<p>Source : Banque mondiale<p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment