geojson
Pre-projected geometry v getting the browser to do it (aka efficiency v flexibility)
If I use this D3 function, aren’t I still forcing the viewer’s browser to do a lot of data processing, which will worsen the performance? The point of pre-processing the data is to avoid this. Or am I overestimating the processing work involved in the d3.geoTransform() function above? Short Answer: You are overestimating the amount … Read more
Geojson map with D3 only rendering a single path in a feature collection
Problem All your features are drawing, you are correctly using your path and enter cycle. To see, set your fill to none: You can see them when inspecting the svg: all the paths are there. Why don’t you see them in the map when they have fill? Because the the polygons are inverted, they cover … Read more
Scaling d3 v4 map to fit SVG (or at all)
Why the data doesn’t project properly The key issue is that your data is already projected. D3 geoProjections use data that is unprojected, or in lat long pairs. Data in the WGS84 datum. Essentially a d3 geoProjection takes spherical coordinates and translates them into planar cartesian x,y coordinates. Your data does not conform to this … Read more
D3.js Drawing geojson incorrectly
The issue is the winding order of the coordinates (see this block). Most tools/utilities/libraries/validators don’t really care about winding order because they treat geoJSON as containing Cartesian coordinates. Not so with D3 – D3 uses ellipsoidal math – benefits of this is include being able to cross the antimeridian easily and being able to select … Read more
Center a map in d3 given a geoJSON object
My answer is close to Jan van der Laan’s, but you can simplify things slightly because you don’t need to compute the geographic centroid; you only need the bounding box. And, by using an unscaled, untranslated unit projection, you can simplify the math. The important part of the code is this: // Create a unit … Read more