You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently to convert D3 and TopoJSON spherical coordinates to equirectangular WGS84 used by standard GeoJSON, you need to project through d3.geoEquirectangular with a scale of 180 / π, and then through d3.geoIdentity to flip the y-axis. For example:
geoproject is not really suitable for this, unless we have a way to opt out of its handling of the polygons' winding order (e.g. d3/d3-geo-projection#185).
My current script for this task is a bit complicated, since it applies geoproject (to apply clipAntemeridian), then fixes the shortcomings:
functionunstitch(a){a=JSON.parse(JSON.stringify(a));// deep copya=d3.geoProject(a,d3.geoEquirectangular().scale(180/Math.PI).translate([0,0]));// flip polygonsfor(constfofa.features){if(f.geometry.type==="Polygon")f.geometry.coordinates.forEach((ring)=>ring.forEach((point)=>(point[1]*=-1)));elseif(f.geometry.type==="MultiPolygon")f.geometry.coordinates.forEach((poly)=>poly.forEach((ring)=>ring.forEach((point)=>(point[1]*=-1))));}// fix winding order (for Fiji in 50m)returnrewind(a);}
Currently to convert D3 and TopoJSON spherical coordinates to equirectangular WGS84 used by standard GeoJSON, you need to project through d3.geoEquirectangular with a scale of 180 / π, and then through d3.geoIdentity to flip the y-axis. For example:
It’d be nice if there were a single built-in projection, say d3.geoWgs84, that did this in one go.
The text was updated successfully, but these errors were encountered: