google route optimizer

can any one help me in formulating the google route optimizer in r in which i have to find the shortest distance among 5 lat longs within same city

The best way to preface a question is with a reproducible example, called a reprex, so that we can better see where you're stuck. Not everyone has used the google route optimizer, but lots of peeps in the community can spot holes in the code.

Assuming you have an object with five pairs of point coordinates, the problem decomposes into two parts:

  1. What is the distance within your projection system between each pair of points i, j?
  2. What traversal of the points minimizes \sum\limits^j\limits_i of distances{_i}{_j}?

With the sf library, you can easily create a points object to contain i and j.

and the igraph library has functions to calculate traversal distances. For as few as five points, this should be fairly straightforward.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.