Divide vector of coordinates into even intervals.

8 ビュー (過去 30 日間)
Hampus Alfredsson
Hampus Alfredsson 2018 年 2 月 22 日
コメント済み: Hampus Alfredsson 2018 年 2 月 23 日
Hi!
I have a long vector of longitude and latitude coordinates representing one bus route. Though the distance between each following pair of coordinates is different through the vector. I want to generate new longitude-latitude coordinates so that I have lots of intervals with same length.

採用された回答

Jim Riggs
Jim Riggs 2018 年 2 月 22 日
Based on your description of the problem, this is what I would do:
Given a vector of lat/lon positions which represents one route, where the distance between points is not evenly spaced. I want to divide this route into N evenly spaced distances.
In order to interpolate on distance, you need to create the distance vector that corresponds to the lat/long vector. Compute the distance from the start of the route for each lat/lon point. E.g. d1 = zero, d2 = the distance from pt1 to pt2. d3 = d2 + distance from pt2 to pt3, etc. This vector is monotonically increasing from zero to the total route length.
Now you interpolate the total distance vector based on your desired distance spacing, then use that to locate the corresponding position in the lat/lon vector. The corresponding point will be bounded by the same index values, and have the same fraction displacement between the bounding values.
  1 件のコメント
Hampus Alfredsson
Hampus Alfredsson 2018 年 2 月 23 日
Yes, I managed to solve the problem by interpolation and some if-restrictions for certain intervals. Thank you

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2018 年 2 月 22 日
You need to have a look on interpolation......Read about interp1.
  2 件のコメント
Hampus Alfredsson
Hampus Alfredsson 2018 年 2 月 22 日
Yes, interpolation works to begin with. But whenever the direction of coordinates become negative(the bus is driving on a road that is slightly back towards its starting point), the interp1 become wrong.
Stephen23
Stephen23 2018 年 2 月 22 日
@Hampus Alfredsson: interpolation works with negative values just as well as it does positive ones. Please make a new comment and upload your code by clicking the paperclip button.

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by