Is there an example of centering a globe on coordinates with Plot?

I’m loving this cheatsheet here on Plot’s mapping features

One question that jumped into my head for a project I’m working on: Is there a helper or example snippet that shows how you might calculate the rotate setting’s Euler angles given a coordinate pair.

My use case is that I’d like to add a single point to a small globe, and have the view of globe centered on that same point. I don’t see an easy way to do that now. And I’m not smart enough about Euler to know the formula for the conversion.

Is there an example of someone sorting it out? Would this make sense as a helper to include in the library?

1 Like

Negate the coordinates to produce the rotation.

So if Tokyo, Japan is at 35.6762° N, 139.6503° E, that corresponds to a [longitude, latitude] of [139.6503, 35.6762]. To rotate the projection to place Tokyo at 0° N, 0° E, you’d use a rotation of [-139.6503, -35.6762].

Plot.plot({
  height: 640,
  inset: 1,
  projection: { type: "orthographic", rotate: [-139.6503, -35.6762] },
  marks: [globe, Plot.dot([[139.6503, 35.6762]], { fill: "red" })]
})
2 Likes

Well that’s a lot easier than I expected! Thanks for the tip. It’s appreciated.

1 Like

For anyone who comes behind me, I worked out my demo here: Interactive locator map / Ben Welsh | Observable

2 Likes