Group Abstract Group Abstract

Message Boards Message Boards

Draw a GeoDisk that covers entire path between 2 locations?

I would like to draw a GeoDisk[] that covers the entire path between 2 given locations. Path can be GeoPath[] or TravelDirections[]. How do i do this? Any suggestions?

Unable to draw a GeoDisk between 2 GeoPositions

POSTED BY: Manjunath Babu
4 Replies
Posted 10 years ago
td = TravelDirections[{Entity["Building", 
    "EmpireStateBuilding::h583b"], 
   Entity["Building", "GrandCentralTerminal::xyg9f"]}];
points = Union[
   Cases[td["TravelPath"] /. 
     GeoPath[GeoPosition[a_], "TravelPath"] -> a, {_, _}, {2}]];
combo = Flatten[
   Table[{points[[i]], points[[j]]}, {i, Length@points - 1}, {j, 
     i + 1, Length@points}], 1];
last = SortBy[{GeoPosition[Mean[#]], #, 
       EuclideanDistance[#[[1]], #[[2]]]} & /@ combo, Last] // Last;
GeoGraphics[{GeoPath@td, 
  GeoDisk[last[[1]], 0.5 GeoDistance[Sequence@last[[2]]]]}]

enter image description here

POSTED BY: Diego Zviovich

I was thinking roughly the same, at first, but it does not always cover all the points:

   points={{40.74789000000001`,-73.98916`},{40.753990000000016`,-73.97420000000001`},{40.75607100561154`,-73.98731010197233`}};
   combo = Subsets[points, {2}];
   last=SortBy[{GeoPosition[Mean[#]],#,EuclideanDistance[#[[1]],#[[2]]]}&/@combo,Last]//Last;
   GeoGraphics[{GeoMarker@GeoPosition@points,GeoDisk[last[[1]],0.5 GeoDistance[Sequence@last[[2]]]]}]

enter image description here

POSTED BY: Sander Huisman

Yes, a smallest disk that has both points inside it.

POSTED BY: Manjunath Babu

Do you want precisely the smallest? I think some iterative algorithm might be the easiest options: draw a circle with a radius that equals the distance to the furthest point. as a function of lat and long, starting at the mean location all of the points. Using FindMinimum (on the radius) the lat and long should be quite quickly found...

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