google api closest pair of points - google-maps-api-3

Is there a google api that will calculate closest pair of points?
Where I can give it many points, and it will calculate the shortest route between them?
thanks

Would the Distance Matrix work for you?
https://developers.google.com/maps/documentation/javascript/distancematrix

Related

Finding the nearest zipcode from a list of zipcodes

I have a list of locations with zipcodes. I have another list of Distribution Centers that serve these locations. Is there anyway to map the nearest DC to each of these locations? I am an extremely green coder, but i have some experience with R
I'd need more information to give you some possible code to solve your problem however, here is one approach to solving your problem.
Convert your zipcodes to longitudes and latitudes.
Not sure what location data you have on your distribution centers, but you should be able to find a way to retrieve the long/lat of each of these.
For each zipcode, compute the the distance to each DC (using their respective longs/lats). To compute the distance, use the haversine formula. Find the minimum of these distances. This is your solution.

Here.com API isoChrone Is Self Interesecting Polygon

Newbie question.
Has anybody run into isoChrone (Drive Time Polygons) where the resulting points represent a self-intersecting polygon?
I presume this is to be expected with the algorithm and underlying network data?
I guess you mean the isoline calculation done by Here API. Do you have a specific scenario where you observe such a self intersecting ploygon ?

Determining shortest distance between Isobaths

I'm interested in finding the shortest distance between two 120m isobaths to determine the interaction of species during the Pleistocene.
Thus far I have found methods to plot the isobaths with package marmap. But have not been able to find functions to determine the shortest distance between isobaths without having to manually measure them as there will be quite a substantial number of measurements involved which would not be efficient to do so manually.
Would appreciate any advice on this, thanks!
Have you tried using the function dist2isobath() in the latest version of marmap (v0.9.1)? Its purpose is to compute great circle distances between any number of points and a given isobath. So you could get the coordinates of points along one of your 120m isobath using contourLines(), then use dist2isobath() to compute the shortest path between each of these points and your second 120m isobath.

Optimal meeting point in an directed graph having 2 starting vertices

What algorithm should I use if in a directed graph I want to find the shortest paths, having 2 starting vertices, so that the paths meet and both have the minimum distance for this to happen.
I would do an All-Pairs-Shortest-Path, find common endpoints, and then find the minimum of (distance(vertex1,endpoint)+distance(vertex2,endpoint)) for all possible endpoints
I would use Dijkstra's to get minimal distance trees for both starting vertices, then add the two distance vectors together and take the minimum. C.B.'s answer is fine, but you don't need the shortest distances between all pairs, so there's some redundant work there.

How to get the nearest X points from point with latitude and longitude?

I have a list of points with latitude and longitude coordinates, from which I want to enter a point say X. I need help coming up with an algorithm to determine the closest 3 list members to that point x.
You'll probably have to use the Haversine Formula. It calculates Great Circle distance between two points on the Earth's surface. Here's a good article explaining that, and here's an answer to a question similar to yours. Hope that helps!
See the method computeDistanceBetween() in the google.maps.geometry.spherical namespace:
https://developers.google.com/maps/documentation/javascript/reference#spherical
Then, here's an old V2 demo that uses Array.sort():
http://maps.forum.nu/gm_array_sort.html
You could combine the two, implementing
computeDistanceBetween() instead of compareDistance() as the sorting function.
Note that this is all done client side.

Resources