Message Boards Message Boards

How to animate a GeoPath on top of a map

Posted 9 years ago

Hi there,

I'm just playing with the Wolfram cloud for the first time. I've made a map of some recent travels which uses a GeoPath to draw a line over the map between the locations.

GeoGraphics[{Red, GeoPath[{"Machu Pichu", "Santiago"}, "Rhumb"]}]

It's basically the example code with my locations added. You can see it here.

What I'm wondering now is if I can create an animation of that line over the image? I tried to look into the animate functions but couldn't see how to apply them to this situation. Any help or point in the right direction would be much appreciated. Thanks!

POSTED BY: Howard Grigg
4 Replies

Some typical example:

capitals = EntityValue[CountryData["Europe"], "CapitalCity"]

positions = EntityValue[capitals, "Position"];
{distance, order} = FindShortestTour[positions];

imgs = ParallelTable[
  GeoGraphics[{
    Red, Thick, GeoPath[positions[[order[[;; k]]]]],
    Red, PointSize[.02], Point[positions]},
   GeoCenter -> GeoPosition[{54.78, 5.73}],
   GeoProjection -> "Equirectangular",
   GeoRange -> {{30, 83}, {-25, 40}},
   ImageSize -> 500]
  , {k, 1, 52}]

If you are working in the Wolfram Cloud:

CloudExport[imgs, "GIF", Permissions -> "Public"]

And for the desktop:

Export["test.gif", imgs]

enter image description here

POSTED BY: Vitaliy Kaurov
Posted 9 years ago

The GIF was created following a relatively slow procedure:

enter image description here

I think you may find the Manipulate/Animate more useful:

Manipulate[
 Show[GeoGraphics[{Red, 
    Arrow@GeoPath[{{y1, x1}, {(y2 - y1)/(x2 - x1) (x - x1) + y1, 
        x}}]}, GeoRange -> {{-50, 5}, {-90, -50}}], 
  PlotRange -> {{-0.2, 0.2}, {-0.4, 0.4}}], {{x, x1 + 0.1, 
   "Santiago"}, x1 + 0.1, x2}]

Perhaps there is a better way to achieve that.

POSTED BY: Sandu Ursu
Posted 9 years ago

Yea that's pretty much what I'm after! Are you able to post your code from that?

POSTED BY: Howard Grigg
Posted 9 years ago

Something like this?

enter image description here

POSTED BY: Sandu Ursu
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract