Finding position at given distance in a GeoPath












9














Is there a way to find the geoposition of a given distance from start in a GeoPath? I want to mark equidistant positions along a track, for example, a mark every 500 km along the path given by



path=GeoGraphics[
GeoPath[{
Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
Entity["City", {"Rochester", "NewYork", "UnitedStates"}],
Entity["City", {"Chicago", "Illinois", "UnitedStates"}]
}, "Rhumb"]
]


Is there a way to find the pos that gives GeoDistance[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],pos]==500 km along the path?










share|improve this question





























    9














    Is there a way to find the geoposition of a given distance from start in a GeoPath? I want to mark equidistant positions along a track, for example, a mark every 500 km along the path given by



    path=GeoGraphics[
    GeoPath[{
    Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
    Entity["City", {"Rochester", "NewYork", "UnitedStates"}],
    Entity["City", {"Chicago", "Illinois", "UnitedStates"}]
    }, "Rhumb"]
    ]


    Is there a way to find the pos that gives GeoDistance[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],pos]==500 km along the path?










    share|improve this question



























      9












      9








      9


      4





      Is there a way to find the geoposition of a given distance from start in a GeoPath? I want to mark equidistant positions along a track, for example, a mark every 500 km along the path given by



      path=GeoGraphics[
      GeoPath[{
      Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
      Entity["City", {"Rochester", "NewYork", "UnitedStates"}],
      Entity["City", {"Chicago", "Illinois", "UnitedStates"}]
      }, "Rhumb"]
      ]


      Is there a way to find the pos that gives GeoDistance[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],pos]==500 km along the path?










      share|improve this question















      Is there a way to find the geoposition of a given distance from start in a GeoPath? I want to mark equidistant positions along a track, for example, a mark every 500 km along the path given by



      path=GeoGraphics[
      GeoPath[{
      Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
      Entity["City", {"Rochester", "NewYork", "UnitedStates"}],
      Entity["City", {"Chicago", "Illinois", "UnitedStates"}]
      }, "Rhumb"]
      ]


      Is there a way to find the pos that gives GeoDistance[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],pos]==500 km along the path?







      geographics






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 28 at 13:10









      Kuba

      103k12201515




      103k12201515










      asked Nov 28 at 12:57









      Gunnar

      462




      462






















          2 Answers
          2






          active

          oldest

          votes


















          7














          Here's my attempt to parametrize the path by arclength, where here arclength is GeoLength.



          First I build up a function that can be used on many values:



          ParametrizeGeoPath[g_GeoPath, t_] := ParametrizeGeoPath[g][t]

          ParametrizeGeoPath[GeoPath[locs_, args___]] :=
          Block[{line, nodes, lens, acc, nf, n1, n2, solver},
          line = GeoGraphics`GeoEvaluate[GeoPath[locs, args]];
          nodes = GeoPosition /@ Reverse[line[[1]], {2}];
          lens = QuantityMagnitude[UnitConvert[GeoLength[GeoPath[#, args]]& /@ Partition[nodes, 2, 1], "Kilometers"]];
          acc = Accumulate[lens];
          nf = Nearest[acc -> {"Index", "Element"}];

          GeoPathParametricFunction[acc, nodes, nf, args]
          ]


          Given a target distance, we can invert GeoLength with FindRoot:



          GeoPathParametricFunction[_, nodes_, __][d_] /; d == 0 := First[nodes]

          GeoPathParametricFunction[acc_, nodes_, __][d_] /; d == Last[acc] := Last[nodes]

          GeoPathParametricFunction[acc_, nodes_, nf_, args___][d_] /; 0 < d < Last[acc] :=
          Block[{i, v, s, n1, n2, dist, root, t = Unique["t"]},
          {i, v} = First[nf[d]];
          If[v > d, i--];
          s = If[i == 0, 0, acc[[i]]];
          n1 = nodes[[i+1, 1]];
          n2 = nodes[[i+2, 1]];

          dist[t_?NumericQ] := s + QuantityMagnitude[UnitConvert[GeoLength[GeoPath[{GeoPosition[n1], GeoPosition[(1-t)n1 + t n2]}, args]], "Kilometers"]];

          root = Quiet@FindRoot[dist[t] == d, {t, .5, 0, 1}];

          (
          GeoPosition[(1-t)n1 + t n2] /. root

          ) /; MatchQ[root, {t -> _Real}]
          ]

          GeoPathParametricFunction[___][d_?NumericQ] = Indeterminate;

          GeoPathParametricFunction /: MakeBoxes[expr:GeoPathParametricFunction[__], _] := InterpretationBox[RowBox[{"GeoPathParametricFunction", "[", ""[Ellipsis]"", "]"}], expr]


          Your example:



          path = GeoPath[{
          Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
          Entity["City", {"Rochester", "NewYork", "UnitedStates"}],
          Entity["City", {"Chicago", "Illinois", "UnitedStates"}]
          }, "Rhumb"];

          gpf = ParametrizeGeoPath[path];

          gpf[500]



           GeoPosition[{43.0932, -77.0359}]



          Manipulate[GeoGraphics[{
          path,
          GeoMarker[gpf[d]]
          },
          PlotLabel -> Row[{"Distance: ", Quantity[d, "Kilometers"]}]],
          {d, 0, gpf[[1, -1]]}
          ]


          enter image description here



          The points returned are very close to the initial path:



          ListLinePlot[
          GeoDistance[path, g /@ Range[0, 1300, 100]],
          TargetUnits -> "Meters",
          AxesLabel -> Automatic,
          DataRange -> {0, 1300}
          ]


          enter image description here






          share|improve this answer























          • Excellent work. I will certainly be using some aspects of your answer in other geo data related work I have been doing.
            – kickert
            Nov 28 at 16:01



















          4














          Here is a function for finding GeoPositions between 2 cities with certain step



          city1 = Entity["City", {"Boston", "Massachusetts", "UnitedStates"}];
          city2 = Entity["City", {"Rochester", "NewYork", "UnitedStates"}];
          city3 = Entity["City", {"Chicago", "Illinois", "UnitedStates"}];

          geopath[c1_, c2_, step_] := Module[{s = First@GeoDistance[c1, c2],
          a = GeoDirection[c1, c2]},
          GeoPath[NestList[GeoDestination[#,{1000 step,a}]&,c1,Floor[s/step]],"Rhumb"]]


          Now if you want to find positions from city1 to city2 every 100 km, type



          geopath[city1, city2, 100]    


          and you will get the positions




          GeoPath[{Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
          GeoPosition[{42.5124, -72.2106}], GeoPosition[{42.6928, -73.4044}],
          GeoPosition[{42.8732, -74.6017}], GeoPosition[{43.0535, -75.8026}],
          GeoPosition[{43.2338, -77.0069}]}, "Rhumb"]







          share|improve this answer























            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "387"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f186878%2ffinding-position-at-given-distance-in-a-geopath%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            7














            Here's my attempt to parametrize the path by arclength, where here arclength is GeoLength.



            First I build up a function that can be used on many values:



            ParametrizeGeoPath[g_GeoPath, t_] := ParametrizeGeoPath[g][t]

            ParametrizeGeoPath[GeoPath[locs_, args___]] :=
            Block[{line, nodes, lens, acc, nf, n1, n2, solver},
            line = GeoGraphics`GeoEvaluate[GeoPath[locs, args]];
            nodes = GeoPosition /@ Reverse[line[[1]], {2}];
            lens = QuantityMagnitude[UnitConvert[GeoLength[GeoPath[#, args]]& /@ Partition[nodes, 2, 1], "Kilometers"]];
            acc = Accumulate[lens];
            nf = Nearest[acc -> {"Index", "Element"}];

            GeoPathParametricFunction[acc, nodes, nf, args]
            ]


            Given a target distance, we can invert GeoLength with FindRoot:



            GeoPathParametricFunction[_, nodes_, __][d_] /; d == 0 := First[nodes]

            GeoPathParametricFunction[acc_, nodes_, __][d_] /; d == Last[acc] := Last[nodes]

            GeoPathParametricFunction[acc_, nodes_, nf_, args___][d_] /; 0 < d < Last[acc] :=
            Block[{i, v, s, n1, n2, dist, root, t = Unique["t"]},
            {i, v} = First[nf[d]];
            If[v > d, i--];
            s = If[i == 0, 0, acc[[i]]];
            n1 = nodes[[i+1, 1]];
            n2 = nodes[[i+2, 1]];

            dist[t_?NumericQ] := s + QuantityMagnitude[UnitConvert[GeoLength[GeoPath[{GeoPosition[n1], GeoPosition[(1-t)n1 + t n2]}, args]], "Kilometers"]];

            root = Quiet@FindRoot[dist[t] == d, {t, .5, 0, 1}];

            (
            GeoPosition[(1-t)n1 + t n2] /. root

            ) /; MatchQ[root, {t -> _Real}]
            ]

            GeoPathParametricFunction[___][d_?NumericQ] = Indeterminate;

            GeoPathParametricFunction /: MakeBoxes[expr:GeoPathParametricFunction[__], _] := InterpretationBox[RowBox[{"GeoPathParametricFunction", "[", ""[Ellipsis]"", "]"}], expr]


            Your example:



            path = GeoPath[{
            Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
            Entity["City", {"Rochester", "NewYork", "UnitedStates"}],
            Entity["City", {"Chicago", "Illinois", "UnitedStates"}]
            }, "Rhumb"];

            gpf = ParametrizeGeoPath[path];

            gpf[500]



             GeoPosition[{43.0932, -77.0359}]



            Manipulate[GeoGraphics[{
            path,
            GeoMarker[gpf[d]]
            },
            PlotLabel -> Row[{"Distance: ", Quantity[d, "Kilometers"]}]],
            {d, 0, gpf[[1, -1]]}
            ]


            enter image description here



            The points returned are very close to the initial path:



            ListLinePlot[
            GeoDistance[path, g /@ Range[0, 1300, 100]],
            TargetUnits -> "Meters",
            AxesLabel -> Automatic,
            DataRange -> {0, 1300}
            ]


            enter image description here






            share|improve this answer























            • Excellent work. I will certainly be using some aspects of your answer in other geo data related work I have been doing.
              – kickert
              Nov 28 at 16:01
















            7














            Here's my attempt to parametrize the path by arclength, where here arclength is GeoLength.



            First I build up a function that can be used on many values:



            ParametrizeGeoPath[g_GeoPath, t_] := ParametrizeGeoPath[g][t]

            ParametrizeGeoPath[GeoPath[locs_, args___]] :=
            Block[{line, nodes, lens, acc, nf, n1, n2, solver},
            line = GeoGraphics`GeoEvaluate[GeoPath[locs, args]];
            nodes = GeoPosition /@ Reverse[line[[1]], {2}];
            lens = QuantityMagnitude[UnitConvert[GeoLength[GeoPath[#, args]]& /@ Partition[nodes, 2, 1], "Kilometers"]];
            acc = Accumulate[lens];
            nf = Nearest[acc -> {"Index", "Element"}];

            GeoPathParametricFunction[acc, nodes, nf, args]
            ]


            Given a target distance, we can invert GeoLength with FindRoot:



            GeoPathParametricFunction[_, nodes_, __][d_] /; d == 0 := First[nodes]

            GeoPathParametricFunction[acc_, nodes_, __][d_] /; d == Last[acc] := Last[nodes]

            GeoPathParametricFunction[acc_, nodes_, nf_, args___][d_] /; 0 < d < Last[acc] :=
            Block[{i, v, s, n1, n2, dist, root, t = Unique["t"]},
            {i, v} = First[nf[d]];
            If[v > d, i--];
            s = If[i == 0, 0, acc[[i]]];
            n1 = nodes[[i+1, 1]];
            n2 = nodes[[i+2, 1]];

            dist[t_?NumericQ] := s + QuantityMagnitude[UnitConvert[GeoLength[GeoPath[{GeoPosition[n1], GeoPosition[(1-t)n1 + t n2]}, args]], "Kilometers"]];

            root = Quiet@FindRoot[dist[t] == d, {t, .5, 0, 1}];

            (
            GeoPosition[(1-t)n1 + t n2] /. root

            ) /; MatchQ[root, {t -> _Real}]
            ]

            GeoPathParametricFunction[___][d_?NumericQ] = Indeterminate;

            GeoPathParametricFunction /: MakeBoxes[expr:GeoPathParametricFunction[__], _] := InterpretationBox[RowBox[{"GeoPathParametricFunction", "[", ""[Ellipsis]"", "]"}], expr]


            Your example:



            path = GeoPath[{
            Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
            Entity["City", {"Rochester", "NewYork", "UnitedStates"}],
            Entity["City", {"Chicago", "Illinois", "UnitedStates"}]
            }, "Rhumb"];

            gpf = ParametrizeGeoPath[path];

            gpf[500]



             GeoPosition[{43.0932, -77.0359}]



            Manipulate[GeoGraphics[{
            path,
            GeoMarker[gpf[d]]
            },
            PlotLabel -> Row[{"Distance: ", Quantity[d, "Kilometers"]}]],
            {d, 0, gpf[[1, -1]]}
            ]


            enter image description here



            The points returned are very close to the initial path:



            ListLinePlot[
            GeoDistance[path, g /@ Range[0, 1300, 100]],
            TargetUnits -> "Meters",
            AxesLabel -> Automatic,
            DataRange -> {0, 1300}
            ]


            enter image description here






            share|improve this answer























            • Excellent work. I will certainly be using some aspects of your answer in other geo data related work I have been doing.
              – kickert
              Nov 28 at 16:01














            7












            7








            7






            Here's my attempt to parametrize the path by arclength, where here arclength is GeoLength.



            First I build up a function that can be used on many values:



            ParametrizeGeoPath[g_GeoPath, t_] := ParametrizeGeoPath[g][t]

            ParametrizeGeoPath[GeoPath[locs_, args___]] :=
            Block[{line, nodes, lens, acc, nf, n1, n2, solver},
            line = GeoGraphics`GeoEvaluate[GeoPath[locs, args]];
            nodes = GeoPosition /@ Reverse[line[[1]], {2}];
            lens = QuantityMagnitude[UnitConvert[GeoLength[GeoPath[#, args]]& /@ Partition[nodes, 2, 1], "Kilometers"]];
            acc = Accumulate[lens];
            nf = Nearest[acc -> {"Index", "Element"}];

            GeoPathParametricFunction[acc, nodes, nf, args]
            ]


            Given a target distance, we can invert GeoLength with FindRoot:



            GeoPathParametricFunction[_, nodes_, __][d_] /; d == 0 := First[nodes]

            GeoPathParametricFunction[acc_, nodes_, __][d_] /; d == Last[acc] := Last[nodes]

            GeoPathParametricFunction[acc_, nodes_, nf_, args___][d_] /; 0 < d < Last[acc] :=
            Block[{i, v, s, n1, n2, dist, root, t = Unique["t"]},
            {i, v} = First[nf[d]];
            If[v > d, i--];
            s = If[i == 0, 0, acc[[i]]];
            n1 = nodes[[i+1, 1]];
            n2 = nodes[[i+2, 1]];

            dist[t_?NumericQ] := s + QuantityMagnitude[UnitConvert[GeoLength[GeoPath[{GeoPosition[n1], GeoPosition[(1-t)n1 + t n2]}, args]], "Kilometers"]];

            root = Quiet@FindRoot[dist[t] == d, {t, .5, 0, 1}];

            (
            GeoPosition[(1-t)n1 + t n2] /. root

            ) /; MatchQ[root, {t -> _Real}]
            ]

            GeoPathParametricFunction[___][d_?NumericQ] = Indeterminate;

            GeoPathParametricFunction /: MakeBoxes[expr:GeoPathParametricFunction[__], _] := InterpretationBox[RowBox[{"GeoPathParametricFunction", "[", ""[Ellipsis]"", "]"}], expr]


            Your example:



            path = GeoPath[{
            Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
            Entity["City", {"Rochester", "NewYork", "UnitedStates"}],
            Entity["City", {"Chicago", "Illinois", "UnitedStates"}]
            }, "Rhumb"];

            gpf = ParametrizeGeoPath[path];

            gpf[500]



             GeoPosition[{43.0932, -77.0359}]



            Manipulate[GeoGraphics[{
            path,
            GeoMarker[gpf[d]]
            },
            PlotLabel -> Row[{"Distance: ", Quantity[d, "Kilometers"]}]],
            {d, 0, gpf[[1, -1]]}
            ]


            enter image description here



            The points returned are very close to the initial path:



            ListLinePlot[
            GeoDistance[path, g /@ Range[0, 1300, 100]],
            TargetUnits -> "Meters",
            AxesLabel -> Automatic,
            DataRange -> {0, 1300}
            ]


            enter image description here






            share|improve this answer














            Here's my attempt to parametrize the path by arclength, where here arclength is GeoLength.



            First I build up a function that can be used on many values:



            ParametrizeGeoPath[g_GeoPath, t_] := ParametrizeGeoPath[g][t]

            ParametrizeGeoPath[GeoPath[locs_, args___]] :=
            Block[{line, nodes, lens, acc, nf, n1, n2, solver},
            line = GeoGraphics`GeoEvaluate[GeoPath[locs, args]];
            nodes = GeoPosition /@ Reverse[line[[1]], {2}];
            lens = QuantityMagnitude[UnitConvert[GeoLength[GeoPath[#, args]]& /@ Partition[nodes, 2, 1], "Kilometers"]];
            acc = Accumulate[lens];
            nf = Nearest[acc -> {"Index", "Element"}];

            GeoPathParametricFunction[acc, nodes, nf, args]
            ]


            Given a target distance, we can invert GeoLength with FindRoot:



            GeoPathParametricFunction[_, nodes_, __][d_] /; d == 0 := First[nodes]

            GeoPathParametricFunction[acc_, nodes_, __][d_] /; d == Last[acc] := Last[nodes]

            GeoPathParametricFunction[acc_, nodes_, nf_, args___][d_] /; 0 < d < Last[acc] :=
            Block[{i, v, s, n1, n2, dist, root, t = Unique["t"]},
            {i, v} = First[nf[d]];
            If[v > d, i--];
            s = If[i == 0, 0, acc[[i]]];
            n1 = nodes[[i+1, 1]];
            n2 = nodes[[i+2, 1]];

            dist[t_?NumericQ] := s + QuantityMagnitude[UnitConvert[GeoLength[GeoPath[{GeoPosition[n1], GeoPosition[(1-t)n1 + t n2]}, args]], "Kilometers"]];

            root = Quiet@FindRoot[dist[t] == d, {t, .5, 0, 1}];

            (
            GeoPosition[(1-t)n1 + t n2] /. root

            ) /; MatchQ[root, {t -> _Real}]
            ]

            GeoPathParametricFunction[___][d_?NumericQ] = Indeterminate;

            GeoPathParametricFunction /: MakeBoxes[expr:GeoPathParametricFunction[__], _] := InterpretationBox[RowBox[{"GeoPathParametricFunction", "[", ""[Ellipsis]"", "]"}], expr]


            Your example:



            path = GeoPath[{
            Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
            Entity["City", {"Rochester", "NewYork", "UnitedStates"}],
            Entity["City", {"Chicago", "Illinois", "UnitedStates"}]
            }, "Rhumb"];

            gpf = ParametrizeGeoPath[path];

            gpf[500]



             GeoPosition[{43.0932, -77.0359}]



            Manipulate[GeoGraphics[{
            path,
            GeoMarker[gpf[d]]
            },
            PlotLabel -> Row[{"Distance: ", Quantity[d, "Kilometers"]}]],
            {d, 0, gpf[[1, -1]]}
            ]


            enter image description here



            The points returned are very close to the initial path:



            ListLinePlot[
            GeoDistance[path, g /@ Range[0, 1300, 100]],
            TargetUnits -> "Meters",
            AxesLabel -> Automatic,
            DataRange -> {0, 1300}
            ]


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 28 at 18:54

























            answered Nov 28 at 15:52









            Chip Hurst

            20.2k15686




            20.2k15686












            • Excellent work. I will certainly be using some aspects of your answer in other geo data related work I have been doing.
              – kickert
              Nov 28 at 16:01


















            • Excellent work. I will certainly be using some aspects of your answer in other geo data related work I have been doing.
              – kickert
              Nov 28 at 16:01
















            Excellent work. I will certainly be using some aspects of your answer in other geo data related work I have been doing.
            – kickert
            Nov 28 at 16:01




            Excellent work. I will certainly be using some aspects of your answer in other geo data related work I have been doing.
            – kickert
            Nov 28 at 16:01











            4














            Here is a function for finding GeoPositions between 2 cities with certain step



            city1 = Entity["City", {"Boston", "Massachusetts", "UnitedStates"}];
            city2 = Entity["City", {"Rochester", "NewYork", "UnitedStates"}];
            city3 = Entity["City", {"Chicago", "Illinois", "UnitedStates"}];

            geopath[c1_, c2_, step_] := Module[{s = First@GeoDistance[c1, c2],
            a = GeoDirection[c1, c2]},
            GeoPath[NestList[GeoDestination[#,{1000 step,a}]&,c1,Floor[s/step]],"Rhumb"]]


            Now if you want to find positions from city1 to city2 every 100 km, type



            geopath[city1, city2, 100]    


            and you will get the positions




            GeoPath[{Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
            GeoPosition[{42.5124, -72.2106}], GeoPosition[{42.6928, -73.4044}],
            GeoPosition[{42.8732, -74.6017}], GeoPosition[{43.0535, -75.8026}],
            GeoPosition[{43.2338, -77.0069}]}, "Rhumb"]







            share|improve this answer




























              4














              Here is a function for finding GeoPositions between 2 cities with certain step



              city1 = Entity["City", {"Boston", "Massachusetts", "UnitedStates"}];
              city2 = Entity["City", {"Rochester", "NewYork", "UnitedStates"}];
              city3 = Entity["City", {"Chicago", "Illinois", "UnitedStates"}];

              geopath[c1_, c2_, step_] := Module[{s = First@GeoDistance[c1, c2],
              a = GeoDirection[c1, c2]},
              GeoPath[NestList[GeoDestination[#,{1000 step,a}]&,c1,Floor[s/step]],"Rhumb"]]


              Now if you want to find positions from city1 to city2 every 100 km, type



              geopath[city1, city2, 100]    


              and you will get the positions




              GeoPath[{Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
              GeoPosition[{42.5124, -72.2106}], GeoPosition[{42.6928, -73.4044}],
              GeoPosition[{42.8732, -74.6017}], GeoPosition[{43.0535, -75.8026}],
              GeoPosition[{43.2338, -77.0069}]}, "Rhumb"]







              share|improve this answer


























                4












                4








                4






                Here is a function for finding GeoPositions between 2 cities with certain step



                city1 = Entity["City", {"Boston", "Massachusetts", "UnitedStates"}];
                city2 = Entity["City", {"Rochester", "NewYork", "UnitedStates"}];
                city3 = Entity["City", {"Chicago", "Illinois", "UnitedStates"}];

                geopath[c1_, c2_, step_] := Module[{s = First@GeoDistance[c1, c2],
                a = GeoDirection[c1, c2]},
                GeoPath[NestList[GeoDestination[#,{1000 step,a}]&,c1,Floor[s/step]],"Rhumb"]]


                Now if you want to find positions from city1 to city2 every 100 km, type



                geopath[city1, city2, 100]    


                and you will get the positions




                GeoPath[{Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
                GeoPosition[{42.5124, -72.2106}], GeoPosition[{42.6928, -73.4044}],
                GeoPosition[{42.8732, -74.6017}], GeoPosition[{43.0535, -75.8026}],
                GeoPosition[{43.2338, -77.0069}]}, "Rhumb"]







                share|improve this answer














                Here is a function for finding GeoPositions between 2 cities with certain step



                city1 = Entity["City", {"Boston", "Massachusetts", "UnitedStates"}];
                city2 = Entity["City", {"Rochester", "NewYork", "UnitedStates"}];
                city3 = Entity["City", {"Chicago", "Illinois", "UnitedStates"}];

                geopath[c1_, c2_, step_] := Module[{s = First@GeoDistance[c1, c2],
                a = GeoDirection[c1, c2]},
                GeoPath[NestList[GeoDestination[#,{1000 step,a}]&,c1,Floor[s/step]],"Rhumb"]]


                Now if you want to find positions from city1 to city2 every 100 km, type



                geopath[city1, city2, 100]    


                and you will get the positions




                GeoPath[{Entity["City", {"Boston", "Massachusetts", "UnitedStates"}],
                GeoPosition[{42.5124, -72.2106}], GeoPosition[{42.6928, -73.4044}],
                GeoPosition[{42.8732, -74.6017}], GeoPosition[{43.0535, -75.8026}],
                GeoPosition[{43.2338, -77.0069}]}, "Rhumb"]








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 28 at 15:40

























                answered Nov 28 at 13:37









                J42161217

                3,712220




                3,712220






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematica Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f186878%2ffinding-position-at-given-distance-in-a-geopath%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                    How to change which sound is reproduced for terminal bell?

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?