I’m making state level school district maps with the geojsons converted from the NCES US school district shapefile. I wrote a Python script for the conversion.
When visualizing them in Plot, I get this if I do not specify a projection, for example for Alaska:
I think this is due to the chart just uses a regular x/y coordinate system.
If I use a projection say “albers-usa”, I get this:
I think the projection treats the whole canvas as US.
How can I have proper projection for a state level map so that: 1- it does not distort, 2- it fills the whole canvas (not just a small portion).
Should I do something at the Python data conversion step? Or is this something I can achieve with just Plot?
So I tried setting a state plane projection (“conic-conformal”) and domain, however the results are inconsistent: Arkansas: (This one works.)
Without projection and domain-
Just setting the type to conic-conformal won’t give you a state plane projection; you also need to set the parallels and rotate (central longitude) options appropriately for each state. For example, the North Carolina state plane (EPSG:32119) is:
You can refer to d3-stateplane for the appropriate values. And lastly you can set the domain option to zoom in so the state fills the plot. Or, you could just use the Mercator projection, which isn’t great, but isn’t terrible and can be the same for all states.
Also, you might try using MapShaper to convert your Shapefile to GeoJSON or TopoJSON while simplifying. That looks to fix the winding order problems Fil mentioned.
Basically, if I don’t set a projection, there is no winding issue and the state shapes fill the entire plot without setting a domain. But the state and district shapes could look a bit wrong since there’s no projection.
Once I set a projection, the shapes look correct, but there will be weird fill on the outside (winding issue?), and it can’t zoom to fill the entire plot.
Most certainly the winding issue—this affects only spherical projections, which explains why you don’t have this issue with “no projection”. Your best bet is to fix the GeoJSON, as Mike mentioned, or use the function I shared in fil/rewind.