Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with projection and geoJSON? #116

Closed
gbazin-eso opened this issue May 19, 2017 · 5 comments
Closed

Problem with projection and geoJSON? #116

gbazin-eso opened this issue May 19, 2017 · 5 comments

Comments

@gbazin-eso
Copy link

gbazin-eso commented May 19, 2017

Hi,

I have an issue with the representation of a geoJSON file. It seems that the contours are, in some cases (depending on the rotation), misinterpreted and inner/outer regions are mixed up. See the attached screenshots and the codepen https://codepen.io/anon/pen/wdYmqL where you can manually rotate the projection.

Do you think it is an intrinsic problem of geoJSON, a projection-related problem, or a anything wrong in my example? Thanks!

mw_nopb
mw_pb

@mbostock
Copy link
Member

Hmm. Well, partly this is expected when you have an orthographic projection where the clip angle is not 90° so the back hemisphere is visible:

untitled 6

If you want to display the whole earth, I think you want to set the clip angle to 180° rather than using antimeridian clipping, if you aren’t already, since you won’t want a cut along the antimeridian.

var projection = d3.geoOrthographic()
    .scale(radius)
    .clipAngle(180);

That seems to fix some of the transient winding order issues, but, it looks like there are other winding order issues, probably because the topology is more interesting with the milky way shape than typical continents.

untitled 7

See the winding order bl.ock for details. You probably need to reverse one (or more) of the rings in the GeoJSON to fix the winding order problem, but I think you’ll have to figure that out by hand. I might look later if I have time.

@mbostock
Copy link
Member

Here’s a fixed-ish version:

https://bl.ocks.org/mbostock/15a373ce034cbc4ad604767c0eac05cb

image

@gbazin-eso
Copy link
Author

Hi,

Indeed. Thank you very much for your help!

Regards,
G.

@gbazin-eso
Copy link
Author

Hi Mike,

Sorry to re-open that. In your example, you use a canvas and it seems that it is not so convenient to use with d3.js. In particular, we want to manipulate many svg elements on top of the milky way. Would you have a solution which works without the canvas?
Thanks ;)

Best regards,
G.

P.S. BTW, d3-celestial https://github.com/ofrohn/d3-celestial (e.g. http://armchairastronautics.blogspot.de/p/skymap.html) shows the same problem with the milky way in orthographic projection.

@mbostock
Copy link
Member

Please use Stack Overflow tag d3.js to ask for help. Although I make an effort to assist everyone that asks, I am not always available to provide help promptly or directly. Stack Overflow provides a better collaborative forum for self-help: tens of thousands of D3-related questions have already been asked there, and some answered questions may be relevant to you.

When asking for help, please include a link to a live example that demonstrates the issue, preferably on bl.ocks.org. It is often impossible to debug from code snippets alone. Isolate the issue and reduce your code as much as possible before asking for help. The less code you post, the easier it is for someone to debug, and the more likely you are to get a helpful response.

If you have a question about D3’s behavior and want to discuss it with other users, also consider the d3-js Google Group or joining the d3-js Slack.

Thank you! 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants