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?


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:

In[]:= london = GeoPosition[Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}]];

In[]:= lansing = GeoPosition[Entity["City", {"Lansing", "Michigan", "UnitedStates"}]];

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

In[]:= dlat = Latitude[lansing] - Latitude[london]
Out[]= Quantity[-8.79021, "AngularDegrees"]

In[]:= dlon = Longitude[lansing] - Longitude[london]
Out[]= 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-orientation of the UK.

In[]:= axis = FromSphericalCoordinates[{1, Pi/2, -Pi/2 + Normal@Longitude[london]}];
Out[]= {-0.00203622, -0.999998, 0};

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

Get the points of our polygon of the UK:

In[]:= UK = First@EntityValue[Entity["Country", "UnitedKingdom"], "Polygon"];

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

In[]:= newUK = GeoPosition@ GeoPositionXYZ[Dot[#, rot] & /@ First@GeoPositionXYZ[UK]];

Now we can plot:

In[]:= GeoGraphics[{GeoMarker[lansing], Polygon[newUK]}]

enter image description here

  • $\begingroup$ Absolutely brilliant! Exactly what I was looking for; thank you!! $\endgroup$ Sep 6 '16 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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