A total solar eclipse will cross much of the United States, plus parts of Canada and Mexico on April 8, 2024. If you’ve never seen a solar eclipse, you should, and if you’re in North America, this is a great chance. Mathematica can help.
Mathematica includes significant data about the eclipse, including when it happens and where it will be.
nextSolarEclipseDate = DateObject[{2024, 4, 8}];
SolarEclipse[nextSolarEclipseDate]
And to visualize that…
a = GeoGraphics[{GeoStyling[None], Opacity[.2], Red,
SolarEclipse[nextSolarEclipseDate, "PartialPhasePolygon",
EclipseType -> "Total"]}];
b = GeoGraphics[{GeoStyling[None],
SolarEclipse[nextSolarEclipseDate, "TotalPhaseCenterLine",
EclipseType -> "Total"]}];
c = GeoGraphics[{GeoStyling[None], Opacity[.4], Red,
SolarEclipse[nextSolarEclipseDate, "TotalPhasePolygon",
EclipseType -> "Total"]}];;
Show[a, b, c,
GeoCenter -> Entity["City", {"Chicago", "Illinois", "UnitedStates"}],
GeoRange -> Quantity[2500, "Miles"]]
Virtually everybody in North America will get at least a partial eclipse, and everybody along that darker band in the middle will get to see a total eclipse. Sorry, Alaska!
Where best to view the thing? In theory one ought to be able to get a list of every city near the center line with this Mathematica code:
eclipseCenter =
;
SolarEclipse[nextSolarEclipseDate, "TotalPhaseCenterLine",
EclipseType -> "Total"]
GeoNearest["City", eclipseCenter, {All, 0}, TimeConstraint -> Infinity]
But this timed out or gave a server error, so I broke the problem into small pieces. First we identify all the states and provinces through which the center line passes. Ideally, we would do this with GeoEntities[SolarEclipse[nextSolarEclipseDate, "TotalPhaseCenterLine", EclipseType -> "Total"], "AdministrativeDivision"]
, but this gives an empty list. And if we replace the CenterLine with the CenterPolygon, the number of AdministrativeDivisions (which includes not merely states but also counties and other units of government) becomes unwieldy. So we break the problem into pieces, identifying just the states and provinces through which the center line passes:
adminEntitiesPoly =
GeoEntities[
SolarEclipse[nextSolarEclipseDate, "TotalPhasePolygon",
EclipseType -> "Total"], "AdministrativeDivision"];
statesAndProvinces =
EntityValue[Entity["Country", "UnitedStates"],
"AdministrativeDivisions"]~Join~
EntityValue[Entity["Country", "Canada"],
"AdministrativeDivisions"]~Join~
EntityValue[Entity["Country", "Mexico"], "AdministrativeDivisions"];
eclipseStates = Intersection[adminEntitiesPoly, statesAndProvinces];
Then, for each of these states and provinces, we identify every city Mathematica knows about, strip out the small ones, and from the rest identify those through which the center line passes. For sorting, I also compute the distance from New York City (where I hang my hat).
nyc = Entity["City", {"NewYork", "NewYork", "UnitedStates"}];
allCities =
Union[Flatten[Map[GeoEntities[#, "City"] &, eclipseStates]]];
allCitiesOfSize = Select[allCities,
QuantityMagnitude[CityData[#, "Population"]] > 50000 &];
eclipseCitiesOnPath = Select[allCitiesOfSize,
QuantityMagnitude[GeoDistance[#, eclipseCenter]] < 1 &];
eclipseCitiesWithPop = SortBy[Map[<|"city" -> #, "pop" -> CityData[#, "Population"], "distance from home" -> GeoDistance[#, nyc]|> &, eclipseCitiesOnPath], Last];
Dataset[eclipseCitiesWithPop]
That’s manageable! And wow, the kids at UI Bloomington are lucky. Let’s see these cities on a map:
d = GeoGraphics[GeoMarker[eclipseCitiesOnPath]]; Show[a, b, c, d,
GeoCenter -> Entity["City", {"Chicago", "Illinois", "UnitedStates"}],
GeoRange -> Quantity[2500, "Miles"],
GeoProjection -> "Equirectangular"]
You see only three markers above rather than four because Cheektowaga is a suburb of Buffalo and their markers overlap. For me, Buffalo is the obvious destination. Let’s examine the eclipse’s path through that town in detail.
GeoGraphics[{GeoStyling[None], Red, Opacity[0.3], Thickness[0.1],
SolarEclipse[nextSolarEclipseDate, "TotalPhaseCenterLine",
EclipseType -> "Total"]}, GeoRange -> Quantity[8, "Miles"],
GeoCenter -> Entity["City", {"Buffalo", "NewYork", "UnitedStates"}],
ImageSize -> Full]
There you have it. The centerline passes about 2.5 miles south of downtown. Weather permitting, everybody here is going to get a great view.