Nomenclature of Units for Territorial Statistics (NUTS)の全国小地域データ(州/都道府県、行政区域は国よりも小さいが、都市より大きい)を使用しています。私はShapefilesとして公式のウェブサイトからそれらを取った。d3.jsでブラウザのNUTSデータをレンダリング
次に、私は、次のコマンドを使用してにGeoJSONにそれらを変換:
ogr2ogr -f GeoJSON europe_admin_sub_units.json NUTS_RG_01M_2013.shp
今、私が何をしたいのか、それがどのように見えるかの感覚を得るために、ブラウザでこれをレンダリングする簡単です。
私はこの簡単なスクリプトを試してみたが、それはうまくいきませんでした:
<!DOCTYPE html>
<meta charset="utf-8">
<style>
/* CSS goes here. */
</style>
<body>
<script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script></script>
<script src="//d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 1160;
var projection = d3.geo.mercator()
.scale(500)
.translate([width/2, height/2]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("data.json", function(error, uk) {
svg.append("path")
.attr("d", path);
});
</script>
それが機能しなかった理由しかし、私は理解していません。
ブラウザのコンソールにエラーはありませんでした。私はChromeを使用しています。
Hereは、本質的に、私が使用しているデータであり、それだけでこのようになりますけれども:
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "NUTS_ID": "AT", "STAT_LEVL_": 0, "SHAPE_AREA": 10.0385472864, "SHAPE_LEN": 27.774664036600001 }, "geometry": { "type": "Polygon", "coordinates":