Locationmode right now only accepts these 3 options: "ISO-3" | "USA-states" | "country names"
I want to make choropleth maps for different countries on provinces level, as equivalent to _locationmode: "USA-states"_. Instead of defining a new _locationmode_ for every country, like "BRA-states" or "ESP-states" maybe it would be better to define a new generic one calles "province" and afterwards define the country using _locations_ option.
Our current topojson files (built in https://github.com/etpinard/sane-topojson using Natural Earth data) contain:
The "full" subunit lists are available here.
In general, we can't use a single locationmode value for all these subunits because they have overlapping values. For example, 'WA' means both Washington state and Western Australia.
I suspect what you're _really_ looking for is either:
'world' scope rendering would be too slow (in SVG at least)choroplethmapbox does it.@nicolaskruchten I suspect you're looking for us to implement
- To provide your own "subunit" topojson (or geojson) in choropleth traces, similar how
choroplethmapboxdoes it.
item here?
Yup. TopoJSON optional for now but basically the same API as we did for mapbox would be great, plus some automatic bounding box logic
- To provide your own "subunit" topojson (or geojson) in choropleth traces, similar how choroplethmapbox does it.
Yes, that's what I'm looking for. The first option also would be nice, but actually it's not hard to make (or find) topojson files for different countries.
Thanks for translating my description into a proper feature request.
Here's my WIP branch:
where a new locationmode value is added in choropleth and scattergeo traces called 'geojson-id' and where much of the corresponding choroplethmapbox logic is reused.
Now regarding
plus some automatic bounding box logic
This is essentially the geo subplot version of https://github.com/plotly/plotly.js/issues/3434. To me, it makes more sense to implement this at the subplot level.
I'm thinking of adding a new layout.geo attribute named fitbounds which would be false by default. When turned on, we would compute the bounds of the data in all traces (i.e. lon/lat pts for scattergeo, polygons for choropleth) on the subplot and "fit" them (i.e. compute the corresponding projection.scale and translation) before first render. This would essentially be an "opt-on" version of our autorange routine.
That's probably a couple more days of work; nothing substantial. Does that sound ok?
... oops, I forgot to paste the link to the demo:https://codepen.io/etpinard/pen/zYxOoEB
That's probably a couple more days of work; nothing substantial. Does that sound ok?
Yes! Can we default it to true for geo subplots that contain only choropleth in geojson mode... somehow?
Also: this would be geo-only right? we would add it to mapbox some other day?
Can we default it to
trueforgeosubplots that contain onlychoroplethingeojsonmode... somehow?
We could, but I'd vote against it for consistency with choroplethmapbox.
Also: this would be
geo-only right? we would add it tomapboxsome other day?
Yes, that's the plan for v1.52.0
what would fitbounds do when not using geojson and/or in the presence of scope?
Having thought about this a bit, I think fitbounds would need to accept two modes, in addition to "off"... One scoped to the entire geojson, and one scoped to locations-only.
Having thought about this a bit, I think
fitboundswould need to accept two modes, in addition to "off"... One scoped to the entire geojson, and one scoped to locations-only.
Sure, good call.