I'm simply trying to convert a .shp file to a geoJSON format using:
ogr2ogr -f geoJSON output.json input.shp
After executing the command nothing seems to be wrong. Here's an excerpt from the output.json
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"properties": { "ID_0": 86, "ISO": "DEU", "NAME_0": "Germany", "ID_1": 1, "NAME_1": "Baden-Württemberg", "NL_NAME_1": null, "VARNAME_1": null, "TYPE_1": "Land", "ENGTYPE_1": "State" },
"geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 8.708400940398242, 47.715581894910606 ], [ 8.713716147005524, 47.701734382960055 ],
...
But when i try to use de JSON file in d3 (http://d3js.org/) to draw SVG polygons the output is just wrong. Since the shp files are displayed correctly in QGIS I think there has to be something wrong with the way i use ogr2ogr
. The SVG I get is not completely wrong but there seems to be a detail I can't find. It seems like it has been turned upside down and somehow distorted into two separated parts.
Here's the javaScript i used to generate the svg:
//dimensions
var w = 2000;
var h = 2000;
var svg = d3.select("#chart").append("svg")
.attr("width", w)
.attr("height", h);
d3.json(
"http://localhost:8888/data/data.json",
function (json) {
var path = d3.geo.path();
svg.append("g")
.attr("class", "black")
.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path);
Does anyone have an idea what went wrong here? I also tried to convert the shp-file using Qgis and myGeodata (http://converter.mygeodata.eu/vector). But neither of them work the way they should.
I'm very new to this whole cartography stuff. So I would be very happy to get some advice.
Thanks very much!