Repository navigation
Add support for custom geojson polygons in choropleth traces #4267
Description
Activity
Our current topojson files (built in https://github.com/etpinard/sane-topojson using Natural Earth data) contain:
- (only) USA states for the 110m resolution
- USA, Brazil and Australian states + Canadian provinces at 50m
The "full" subunit lists are available here.
In general, we can't use a single
locationmodevalue 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:
- Add topojson files for the 10m resolution to have subunits from more countries available to choropleth traces. We would consider doing this only for scoped geo maps, as in the
'world'scope rendering would be too slow (in SVG at least) - To provide your own "subunit" topojson (or geojson) in choropleth traces, similar how
choroplethmapboxdoes 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?
- To provide your own "subunit" topojson (or geojson) in choropleth traces, similar how
Yup. TopoJSON optional for now but basically the same API as we did for mapbox would be great, plus some automatic bounding box logic
Reacted by etpinard- 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.
- changed the title
[-][Feature request] make location mode extendible[/-][+]Add support for custom geojson polygons in choropleth traces[/+]on Nov 20, 2019 Here's my WIP branch:
where a new
locationmodevalue is added inchoroplethandscattergeotraces called'geojson-id'and where much of the correspondingchoroplethmapboxlogic is reused.
Now regarding
plus some automatic bounding box logic
This is essentially the
geosubplot version of #3434. To me, it makes more sense to implement this at the subplot level.I'm thinking of adding a new
layout.geoattribute namedfitboundswhich would befalseby default. When turned on, we would compute the bounds of the data in all traces (i.e. lon/lat pts forscattergeo, polygons forchoropleth) on the subplot and "fit" them (i.e. compute the correspondingprojection.scaleand 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
trueforgeosubplots that contain onlychoroplethingeojsonmode... somehow?Also: this would be
geo-only right? we would add it tomapboxsome other day?Can we default it to
trueforgeosubplots that contain onlychoroplethingeojsonmode... somehow?We could, but I'd vote against it for consistency with
choroplethmapbox.Reacted by Nicolas KruchtenAlso: this would be
geo-only right? we would add it tomapboxsome other day?Yes, that's the plan for
v1.52.0Reacted by Nicolas Kruchtenwhat would
fitboundsdo when not usinggeojsonand/or in the presence ofscope?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.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.
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.