Skip to content

Instantly share code, notes, and snippets.

@johardi
Last active August 29, 2015 14:04
Show Gist options
  • Save johardi/74d9705d5c5a7b215faa to your computer and use it in GitHub Desktop.
Save johardi/74d9705d5c5a7b215faa to your computer and use it in GitHub Desktop.
Kepemilikan Tanah Tempat Tinggal, BPS 2010

Grafik batang di atas menampilkan sepuluh provinsi teratas berdasarkan jenis sertifikat kepemilikan tanah, diurutkan menurut persentase populasi kepemilikan. Berdasarkan Badan Pusat Statistik, terdapat 4 jenis bukti kepemilikan tanah tempat tinggal:

  • Sertifikat Hak Milik (SHM) atas nama Anggota Rumah Tangga (ART),
  • Sertifikat Hak Milik bukan atas nama ART,
  • Sertifikat lain (cth. SHGB, SHP, SSRS), dan
  • Lainnya (cth. Girik, Akte Jual Beli Notaris/PPAT, dll).

Kredit grafik: Mike Bostock.

Sumber data: Badan Pusat Statistics.

create table ppat2010 (
kode_provinsi integer,
nama_provinsi varchar(255),
kode_kabkota integer,
nama_kabkota varchar(255),
bukti_hak_milik varchar(255),
jumlah_rumah_tangga integer,
latitude decimal(8,5),
longitude decimal(8,5)
)
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background: #fcfcfa;
color: #333;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: 1em auto 4em auto;
position: relative;
width: 700px;
}
svg {
font: 10px sans-serif;
}
#menu {
font-size: 13px;
}
.bar rect {
fill: steelblue;
}
.bar:hover rect {
fill: brown;
}
.value {
fill: white;
}
.axis path, .axis line {
fill: none;
stroke: none;
shape-rendering: crispEdges;
}
.x.axis line {
stroke: #fff;
stroke-opacity: .8;
}
.y.axis line {
stroke: #000;
}
</style>
<body>
<p id="menu">Jenis: <select></select>
<script src="http://d3js.org/d3.v2.min.js"></script>
<script>
var margin = {top: 20, right: 40, bottom: 10, left: 160},
width = 750,
height = 250 - margin.top - margin.bottom;
var format = d3.format(".1%"),
states,
house;
var x = d3.scale.linear()
.range([0, width]);
var y = d3.scale.ordinal()
.rangeRoundBands([0, height], .1);
var xAxis = d3.svg.axis()
.scale(x)
.orient("top")
.tickSize(-height - margin.bottom)
.tickFormat(format);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.style("margin-left", -margin.left + "px")
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("g")
.attr("class", "x axis");
svg.append("g")
.attr("class", "y axis")
.append("line")
.attr("class", "domain")
.attr("y2", height);
var menu = d3.select("#menu select")
.on("change", change);
d3.csv("ppat2010.csv", function(data) {
states = data;
var houses = d3.keys(states[0]).filter(function(key) {
return key != "Nama Provinsi" && key != "Total Kepemilikan";
});
states.forEach(function(state) {
houses.forEach(function(house) {
state[house] = state[house] / state['Total Kepemilikan'];
});
});
menu.selectAll("option")
.data(houses)
.enter().append("option")
.text(function(d) { return d; });
menu.property("value", "SHM atas nama ART");
redraw();
});
var altKey;
d3.select(window)
.on("keydown", function() { altKey = d3.event.altKey; })
.on("keyup", function() { altKey = false; });
function change() {
clearTimeout(timeout);
d3.transition()
.duration(altKey ? 7500 : 750)
.each(redraw);
}
function redraw() {
var house1 = menu.property("value"),
top = states.sort(function(a, b) { return b[house1] - a[house1]; }).slice(0, 10);
console.log(top);
y.domain(top.map(function(d) { return d['Nama Provinsi']; }));
var bar = svg.selectAll(".bar")
.data(top, function(d) { return d['Nama Provinsi']; });
var barEnter = bar.enter().insert("g", ".axis")
.attr("class", "bar")
.attr("transform", function(d) { return "translate(0," + (y(d['Nama Provinsi']) + height) + ")"; })
.style("fill-opacity", 0);
barEnter.append("rect")
.attr("width", house && function(d) { return x(d[house]); })
.attr("height", y.rangeBand());
barEnter.append("text")
.attr("class", "label")
.attr("x", -3)
.attr("y", y.rangeBand() / 2)
.attr("dy", ".35em")
.attr("text-anchor", "end")
.text(function(d) { return d['Nama Provinsi']; });
barEnter.append("text")
.attr("class", "value")
.attr("x", house && function(d) { return x(d[house]) - 3; })
.attr("y", y.rangeBand() / 2)
.attr("dy", ".35em")
.attr("text-anchor", "end");
x.domain([0, top[0][house = house1]]);
var barUpdate = d3.transition(bar)
.attr("transform", function(d) { return "translate(0," + (d.y0 = y(d['Nama Provinsi'])) + ")"; })
.style("fill-opacity", 1);
barUpdate.select("rect")
.attr("width", function(d) { return x(d[house]); });
barUpdate.select(".value")
.attr("x", function(d) { return x(d[house]) - 3; })
.text(function(d) { return format(d[house]); });
var barExit = d3.transition(bar.exit())
.attr("transform", function(d) { return "translate(0," + (d.y0 + height) + ")"; })
.style("fill-opacity", 0)
.remove();
barExit.select("rect")
.attr("width", function(d) { return x(d[house]); });
barExit.select(".value")
.attr("x", function(d) { return x(d[house]) - 3; })
.text(function(d) { return format(d[house]); });
d3.transition(svg).select(".x.axis")
.call(xAxis);
}
var timeout = setTimeout(function() {
menu.property("value", "SHM atas nama ART").node().focus();
change();
}, 5000);
d3.select(self.frameElement).style("height", 310 + "px");
</script>
:ppat2010
a dcat:Dataset ;
dct:title "Data Kepemilikan Tanah Tempat Tinggal, BPS 2010" ;
dcat:keyword "sertifikat", "certificate", "kepemilikan rumah", "house ownership", "bps", "2010" ;
dct:issued "2014-07-18"^^xsd:date ;
dct:modified "2014-07-18"^^xsd:date ;
dcat:contactPoint <http://ha.rdi.io/jo/contact> ;
dct:language <http://id.loc.gov/vocabulary/iso639-1/id> ;
dcat:distribution :ppat2010-csv ;
.
:ppat2010-csv
a dcat:Distribution ;
dcat:downloadURL <https://gist.github.com/johardi/74d9705d5c5a7b215faa#file-ppat2010-csv> ;
dct:title "CSV distribution of Data Kepemilikan Tanah Tempat Tinggal BPS 2010" ;
dcat:mediaType "text/csv" ;
dcat:byteSize "1606"^^xsd:decimal ;
.
Nama Provinsi Total Kepemilikan SHM atas nama ART SHM bukan atas nama ART Sertifikat lain Lainnya
Papua 115649 97371 10251 1378 6649
Riau 591194 326357 45347 17573 201917
Nusa Tenggara Timur 360355 248084 39398 5304 67569
Gorontalo 96479 59194 10548 1131 25606
Sumatera Utara 1428479 657812 90282 21895 658490
Jambi 371407 209105 44259 4127 113916
Jawa Tengah 5914530 3103448 576356 67723 2167003
Bengkulu 233792 150940 24723 1875 56254
Kepulauan Riau 172745 88654 7713 34608 41770
Sulawesi Selatan 961590 487867 75713 18315 379695
Sulawesi Tengah 269261 175876 34494 2300 56591
Kalimantan Tengah 244304 154262 24947 6238 58857
Kalimantan Selatan 443056 227906 37467 12439 165244
Papua Barat 51926 43894 4362 977 2693
Sumatera Selatan 914346 470299 88703 24452 330892
Kalimantan Timur 399469 235306 41714 11916 110533
Nanggroe Aceh Darussalam 573382 300103 18657 3605 251017
D I Yogyakarta 648560 411855 122133 8463 106109
Maluku Utara 69702 56681 4999 373 7649
Bali 451023 282871 101723 5999 60430
Kepulauan Bangka Belitung 137215 61578 9911 4884 60842
Jawa Barat 6405906 2303047 367176 130788 3604895
Lampung 1239426 593373 119817 16572 509664
Kalimantan Barat 461736 287627 47022 6281 120806
Sulawesi Tenggara 260614 159158 34771 2112 64573
DKI Jakarta 1113219 594142 121524 30557 366996
Nusa Tenggara Barat 448181 236168 80569 7291 124153
Sumatera Barat 343533 214307 41021 4794 83411
Jawa Timur 6690381 2510919 531825 123231 3524406
Sulawesi Utara 250222 125770 19159 5045 100248
Sulawesi Barat 113806 58352 11532 1256 42666
Banten 1527931 613819 81246 34309 798557
Maluku 88750 61050 9874 2887 14939
select substr(nama_provinsi, 7) "Nama Provinsi",
sum(jumlah_rumah_tangga) "Total Kepemilikan",
sum(case when bukti_hak_milik = 'SHM atas nama ART' then jumlah_rumah_tangga else 0 end) "SHM atas nama ART",
sum(case when bukti_hak_milik = 'SHM bukan atas nama ART' then jumlah_rumah_tangga else 0 end) "SHM bukan atas nama ART",
sum(case when bukti_hak_milik = 'Sertifikat lain' then jumlah_rumah_tangga else 0 end) "Sertifikat lain",
sum(case when bukti_hak_milik = 'Lainnya' then jumlah_rumah_tangga else 0 end) "Lainnya"
from ppat2010
group by nama_provinsi
order by "Sertifikat lain"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment