Skip to content

USA-states incorrectly drawn as foreign regions in high resolution choropleth #3779

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

Closed
Thlayli opened this issue Apr 16, 2019 · 5 comments
Closed
Assignees
Labels
bug something broken
Milestone

Comments

@Thlayli
Copy link

Thlayli commented Apr 16, 2019

I’ve been working on a choropleth (through plotly.py originally) and things had been going fine at 110 resolution, but I decided to switch to 50 and things got weird. The problem I’m seeing is that I’m providing a list of ‘USA-states’ and it’s deciding to map some of them to similarly named world states, e.g. WA (Washington) is mapped on Western Australia and PA (Pennsylvania) is mapped on Pará, Brazil. This problem does not occur at all at the lower 110 resolution where WA is correctly mapped to the USA state as requested.

I’d actually like to take advantage of this hidden feature for other projects but I can only get it to happen through this glitch, not through choice. I’ve tried various other formats like "WA, AUS" or "AUS-WA" and both "USA-states" and "countries" formats. The only thing that causes Western Australia to be drawn is putting “WA” and “USA-states” and resolution=50.

https://jsfiddle.net/Thlayli/3jza9sov/
or
https://plot.ly/~thlayli/22/number-of-artists-by-country-or-region/#/ 1

@etpinard
Copy link
Contributor

Thanks for reporting.

@etpinard etpinard added the bug something broken label Apr 16, 2019
@etpinard etpinard self-assigned this Apr 16, 2019
@etpinard
Copy link
Contributor

Ha, that's a shame

var gd = document.querySelector('.js-plotly-plot')
gd._fullLayout.geo._subplot.topojson.objects.subunits.geometries.map(g => g.id)

has duplicate ids in it:

image

Looks like we'll have to patch: https://github.com/etpinard/sane-topojson


That said, I wonder if some users out there are using locationmode: 'USA-states to show (incorrectly) Brazil, Australia and Canada sub-divisions?

@Thlayli
Copy link
Author

Thlayli commented Apr 17, 2019

I'd do it if it was predictable. :D

@etpinard
Copy link
Contributor

I'd do it if it was predictable.

Do what exactly? You mean you would use locationmode: 'USA-states' to draw e.g. Brazil sub-division choropleths? That's sounds odd. We should probably add a new locationmode value (e.g. 'subdivisons') for choropleths of the likes.

@Thlayli
Copy link
Author

Thlayli commented Apr 17, 2019

Yeah, I meant I would plot non-USA regions on a world map if I could specify both country and region code.

@etpinard etpinard added this to the v1.48.0 milestone Apr 26, 2019
etpinard added a commit that referenced this issue May 10, 2019
This is important as the Natural Earth files
nclude state/provinces from USA, Canada, Australia and Brazil
which have some overlay in their two-letter ids. For example,
'WA' is used for both Washington state and Western Australia.
As subunits from USA and Canada never conflict, filtering out features
south of the equator suffices to fix #3779

A better fix would have us add a "governing unit" properties in subunit features
in the `sane-topojson` package to avoid conflicts.
etpinard added a commit that referenced this issue May 16, 2019
etpinard added a commit that referenced this issue May 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

2 participants