Closed misha-panyushkin closed 6 years ago
You're not doing anything wrong! The reason for the bad display is that D3 doesn't have the same definition of geojson as the others. (See the introduction in https://github.com/d3/d3-geo).
In d3-geo, all the lines follow the geodesic lines (great circles), and they don't need to be cut at the antimeridian (longitude=180°).
To convert your results to the standard geojson you can use the d3.geoProject utility from https://github.com/d3/d3-geo-projection and do this:
projected = d3.geoProject(
d3.geoProject(
polygons,
d3
.geoEquirectangular()
.scale(180 / Math.PI)
.translate([0, 0])
),
d3.geoIdentity().reflectY(true)
)
After this operation you should be able to see the features correctly. https://gist.github.com/Fil/f67b0f6ccfa1f072c555775e331c307b
As you can see if you inspect the resulting structure, one of the polygons has been transformed to a multipolygon, which doesn't make sense from a topological point of view… and that is basically the explanation for this (very inconvenient) difference.
We should probably offer a simpler API for this "solution".
Another reference here: https://github.com/d3/d3-geo/issues/104
@Fil many thanks! I've spent a lot of time finding solution. And now I understand the correct approach!
Hi, I'm trying to build Voronoi diagram for "infinite horizon" map. The points - are the cities with defined coordinates
[lat, lon]
.Input:
geoJSON
Links
Triangles
Polygons ![image](https://user-images.githubusercontent.com/890700/45123157-9fc7f200-b16e-11e8-8452-aa9a7ca17707.png)
d3.geoVoronoi(geoJSON).links()
d3.geoVoronoi(geoJSON).triangles()
d3.geoVoronoi(geoJSON).polygons()
Can't understand what I'm doing wrong. I will appreciate any help on these.