1
$\begingroup$

I have a list of lat/long pairs and would like to interpolate. Sending the list of lists of lat/long directly to the first form in the documentation as ListInterpolation[{f1,f2,..}] noting "The function values fi can be real or complex numbers, or arbitrary symbolic expressions." doesn't and cannot work as the structure of the argument looks identical to the 2nd form ListInterpolation [{{x1,f1}, ..}]. So now hard to restructure the list so that that {{i,{lat1,long1}},{i+1,{lat2,long2}},..} and I'm sure that'll work. But I don't understand well the use of Hold and other controls, so is there a way to tell ListInterpolation that the following should be treated in the 1st form instead of the second? For this instance, it is easy to wrap the lat/long in GeoPosition and then the list is of elements and with InterpolationOrder -> 1 it seems to work. However, the general question remains. How to instruct Mathematica to treat a structure one way when it also matches another?

$\endgroup$
2
  • $\begingroup$ The reason for interpolation is I wanted to find the closest approach to some other point. I was planning to use GeoDistance in a FindMinimum and figured a function made from line segments (order -1) of order - 2 interpolation would be the easiest way to form the "continuous" function so findmin would work over real numbers and the GeoDistance would be reasonably smooth. $\endgroup$
    – Paul
    Apr 21, 2023 at 4:29
  • $\begingroup$ Use Interpolation[{{lat1,long1},{lat2,long2}, ....}] $\endgroup$ Apr 21, 2023 at 8:36

1 Answer 1

1
$\begingroup$
$Version

(* "13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)" *)

Clear["Global`*"]

SeedRandom[1234];

pts = RandomGeoPosition[
   Entity["Country", "UnitedStates"], 10][[1]]

(* {{45.8748, -68.5756}, {36.8119, -100.915}, {33.4359, -95.5268}, {47.2874, \
-97.6259}, {42.7483, -99.5294}, {35.3193, -97.3695}, {46.0988, -91.3056}, \
{38.3082, -121.194}, {47.0701, -117.238}, {34.4971, -104.295}} *)

Given a list of {lat, longs}, it is not clear why you need to interpolate them.

GeoListPlot[GeoPosition[SortBy[pts, Last]],
 Joined -> True]

enter image description here

GeoGraphics[{Red, AbsoluteThickness[2],
  GeoPath[GeoPosition /@ SortBy[pts, Last]]}]

enter image description here

GeoListPlot[GeoPosition[
  pts[[Most[FindShortestTour[pts][[2]]]]]],
 Joined -> True]

enter image description here

GeoGraphics[{Red, AbsoluteThickness[2],
  GeoPath[GeoPosition /@
    pts[[Most[FindShortestTour[pts][[2]]]]]]}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.