🏠 back to Observable

d3.geo bbox

Well…, I am a relative beginner in d3.js and I’m trying to figure out how this whole awesome thing works… Here is my problem… After calculating the bbox of my geographical object (e.g. China) with d3.geoBounds(), I try to display the bbox on my map on an orthographic projection. It seems to work a little. But in reality, it doesn’t work at all when I take another country. I must be wrong somewhere but I don’t understand where. Any help would be appreciated. Work in progress.
https://next.observablehq.com/d/6efcbadee2774362

I could not find how to fix it, but it seems that your north-south lines are OK, while your east-west lines are not. I understand it’s because what is drawn is the arc of the great circle (which center is the center of the earth), which is what you want for the meridians, but not for the parallels (here: you want an arc of the “horizontal” circle which center is placed at the same latitude)

I looked at how parallels are done in graticules (d3-geo/graticule.js at master · d3/d3-geo · GitHub), and if I understand correctly, they are sampled every 1°! And interpolated along the great circle in-between, which is incorrect, but not visible at this scale… So the solution should be to create N intermediate points on the top and bottom sides of your box.

3 Likes