Given a shapefile :
Natural_earth/ne_10m_admin_0_sovereignty.zip
Given we want to reproject it for a D3js data viz, we could reproject at different levels.
1. Get a reprojected shapefile (1), using ogr2ogr
:
ogr2ogr -f 'ESRI Shapefile' -t_srs 'EPSG:...' output.shp input.shp
OR 2. get a reprojected topojson (2), using (npm) topojson.js
:
topojson \
-o output.topo.json
--projection 'd3.geo.albersUsa()' \
-q 1e5 \
-s 1 \
-- input.shp
OR 3. get a reprojected D3js data / SVG (1), D3js code including:
var path = d3.geo.path()
.projection(d3.geo.albersUsa()) // unsure of this syntaxe, confirmation welcome, just delete this comment.
Overview:
Mike Bostock > Projected Topojson informs us that the 1st and 2nd ways "eliminates the need to project the geometry while rendering, improving performance [...] since the importance of each point is measured in area on-screen rather than on the Earth’s surface." in short, the end pixel quality/file weight ratio is better.
On the other hand, reprojecting the geometry while rendering allow a more agile, last minute projection.
Knowing more ?
This is all what I know. If someone could explain more on these ways, share helping resources for parameters (list of ogr's EPSG, list of d3js projections), and respective benefits/weakness for each, it could be a very interesting parallel manual.
Note: I will give my shoot-answer at it but I just start to dig on it. I guess there are more experienced people around.