I've created a GeoGraphics object from data I collected on a recent trip across part of Michigan, like so:


I'd really like to overlay another country to scale in the center of this image to give a more tangible measure of the length of the path, but I'm running into trouble keeping everything lined up correctly. If I do something like

mathematica command

I just get the portion of the globe that encompasses both my path and the UK:


How can I "move" the to-scale outline of the UK over the outline of my path?


1 Answer 1


Due to the non-sphericity of the Earth, there is no exact way of rotating a polygon, but the following is a good approximation.

Suppose we want to rotate the UK polygon so that London is moved to Lansing.

sourcePosition = GeoPosition[Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}]];
destinationPosition = GeoPosition[Entity["City", {"Lansing", "Michigan", "UnitedStates"}]];

That means we need to implement these changes in latitude and longitude:

dlat = Latitude[destinationPosition] - Latitude[sourcePosition]
(* Quantity[-8.79021, "AngularDegrees"] *)

dlon = Longitude[destinationPosition] - Longitude[sourcePosition]
(* Quantity[-84.4396, "AngularDegrees"] *)

We will do it in two steps, first changing latitudes along the London meridian and then changing longitudes along the Lansing parallel. This will preserve the north-south orientation of the UK.

axis = FromSphericalCoordinates[{1, Pi/2, -Pi/2 + Normal@Longitude[sourcePosition]}]
(* {-0.00203622, -0.999998, 0} *)

rot = Transpose[RotationMatrix[dlon, {0, 0, 1}].RotationMatrix[dlat, axis]];

Get the points of our polygon of the UK:

sourcePolygon = First@EntityValue[Entity["Country", "UnitedKingdom"], "Polygon"];

Finally perform the rotation (note that we transform with the rot matrix on the right, which explains the use of Transpose above):

destinationPolygon = GeoPosition@GeoPositionXYZ[Dot[#, rot] & /@ First@GeoPositionXYZ[sourcePolygon]];

Now we can plot.

GeoGraphics[{GeoMarker[destinationPosition], Polygon[destinationPolygon]}]

enter image description here

  • $\begingroup$ Absolutely brilliant! Exactly what I was looking for; thank you!! $\endgroup$
    – rayhem
    Sep 6, 2016 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.