d3-geo
d3-geo copied to clipboard
Add functionality to rewind geojson into old-style d3 geojson
Triggered by https://gis.stackexchange.com/questions/392452/why-d3-js-works-only-with-geojson-violating-right-hand-rule
It would be useful to have functionality with d3 to rewind right-hand geojson into left-hand geojso.
Right now displaying RFC 7946 geojson requires importing extra library.
(and maybe add some warning on detecting small areas misinterpreted by D3 to be planet-covering area with a small hole? this D3 behavior was really confusing. I was looking for bugs in my code for hours.)
BTW, ad https://github.com/d3/d3-geo/pull/79#issuecomment-280935242
I’m disappointed that RFC 7946 standardizes the opposite winding order to D3, Shapefiles and PostGIS. And I don’t see an easy way for D3 to change its behavior, since it would break all existing (spherical) GeoJSON used by D3. I’d be interested to see an empirical analysis of GeoJSON use in practice to see what winding order is commonly used.
right-hand winding order seems to be clearly more and more standard to me (see for example QGIS which will not open them at all) and D3 seems to growing oddity. Especially as
result is the same whether the exterior ring is clockwise or anticlockwise
appears to not be true in many cases
Or maybe have opt-in setting "I want to use geojson, not d3-old-style-geojson"?
I agree it would be useful. Can we follow the conversation at https://github.com/d3/d3-geo/issues/138?
Closing as duplicate of #138. Current solution at https://observablehq.com/@fil/rewind