# Projection for state level map in Plot

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?

Thanks!

https://mbostock.observablehq.cloud/framework-help/2024-05-01-projection-domain/

1 Like

Thanks! @mbostock

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-

With projection and domain-

California:
Without projection and domain-

With projection and domain-

Maryland:
Without projection and domain-

With projection and domain-

What might cause this? Is there something I should do when splitting the shapefile?

Geo: Rewind / Fil | Observable might help

1 Like

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:

``````  projection: {
type: "conic-conformal",
parallels: [34 + 20 / 60, 36 + 10 / 60],
rotate: [79, 0]
},
``````

Whereas the Arkansas north state plane (EPSG:26951) is:

``````  projection: {
type: "conic-conformal",
parallels: [34 + 56 / 60, 36 + 14 / 60],
rotate: [92, 0]
},
``````

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.

1 Like

@mbostock @Fil
Could setting a projection and the winding issue be related? (The former somehow triggers the latter?)

For some reason, for Alabama, if I don’t set a projection, it looks like this:

If I set it to be mercator and set the domain, it becomes this:

The state becomes really small and has light blue fill around it.

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.

1 Like

Thanks! @Fil