-
Notifications
You must be signed in to change notification settings - Fork 558
Description
I am wondering if MapShaper does an even cleverer job to projection than D3. The issues I have is converting a shapefile for Germany into GeoJSON: It displays perfectly in Mapshaper but I can't reproduce the same rendering with standard D3js code (like the example in Scott Murrays book, see at the end of this post),
However converting the same shapefile with ogr2ogr on the commandline works
ogr2ogr -f "GeoJSON" -t_srs crs:84 germany.json vg250_L.shp
It might well be a misunderstanding of D3 on my part (wrong projection?), so forgive me beforehand. This is how I loaded the GeoJSON that I generated with the above ogr2ogr command
//Define map projection
var projection = d3.geo.mercator()
.center([14.5,52.5])
.scale(3000);
//Define path generator
var path = d3.geo.path()
.projection(projection);
//Create SVG element
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
//Load in GeoJSON data
d3.json("germany.json", function(json) {
//Bind data and create one path per GeoJSON feature
svg.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path);
});
The shapefile discussed in this example is from the open data portal for Germany: http://www.geodatenzentrum.de/auftrag1/archiv/vektor/vg250_kompakt/2014/vg250_2014-01-01.utm32s.shape.kompakt.zip
If I had one wish, it would be that Mapshaper generated some example D3js code that displays the GeoJSON the same way Mapshaper does itself.
