I’d like to create a choropleth of New York’s 27 congressional districts. I assumed that this was the same thing as the county choropleth which follows the FIPs numbers, but that is not the case given that there are 62 FIps numbers for New York and only 27 Congressional districts. Does this mean I would have to specify the borders myself? Has anyone done something like this where I could take a look at an example? Thank you!
The plotly.py ships with the geometry info for all of the US countires, which is the basis for the country choropleth. Supporting congressional districts would require another set of geometry. So there’s no built-in way to do this at this point.
You’re also welcome to open a feature request at https://github.com/plotly/plotly.py/issues. We don’t have any plans to work on this in the near future, but it’s helpful to have a record of what people are interested in doing to inform our future priorities.
Was there anything you had in mind for making this “an official Hacktoberfest item”?
In any case, the next step would be to open a feature request issue at https://github.com/plotly/plotly.py/issues that describes the use case. Also, include any information you’ve already found regarding where the get the congressional district geometry, and any thoughts you have on the implementation/API. This way we can talk through the high level approach and API before you, or someone else, gets too far into coding it.
Hi @mbkupfer, sure. Feel free to add your references regarding the metro areas to the plotly.py issue above. At this point the county map is only available in plotly.py (not plotly.js) so it would probably be easier to add in to plotly.py than plotly.js at the moment.
And feel free to chime in with your thoughts on the same questions I raised to @thedatasleuth. In particular, what the API could look like and what kind of unique identifiers should be used to specify values for each metro areas (Is there something like FIPS codes for these?)
Hi @jmmease, that sounds good. I didn’t realize that countymaps was only available to plotly.py, but that now makes sense given the extra dependencies. I’m working in dash though so an only python solution would still be fine.
In particular, what the API could look like
Ideally, this would have the same name as the _county_choropleth.create_choropleth() function.
To allow something like this though, fig = ff.create_choropleth(area_codes=area_codes, values=values, ... )
or in @thedatasleuth’s case, fig = ff.create_choropleth(congressional_codes=congressional_codes, values=values, ... ) would require some restructuring to the current code.
To keep backwards compatibility, I’d probably create multiple create_choropleth() functions with some logic that decides whether we create a county, congressional, metro, or whatever type of choropleth figure. How does that sound?
and what kind of unique identifiers should be used to specify values for each metro areas (Is there something like FIPS codes for these?)
Yes, areas do have unique identifiers. Here is a link to the area definition file that is provided by the US Bureau of Labor Statistics: https://www.bls.gov/oes/current/area_definitions_m2017.xlsx Codes are in column D ‘MSA code (including MSA divisions)’
I’ll continue this on the PR thread as well. Really looking forward to getting involved with this!