フィルターのクリア

rotate polygon in geographic axes

23 ビュー (過去 30 日間)
Mike D.
Mike D. 2020 年 2 月 21 日
コメント済み: Mike D. 2024 年 7 月 12 日 0:49
I have a n-sided polygon with vertices as (lat,lon) coordinates. I plot this on a geographic axes. I want to rotate it and end up with a new rotated set of (lat,lon) coordinates. I don't want a filled polygon, but perhaps I could adjust the transparency if that's the only way (such as patch). Here is what I tried, but not sure it works accurately due to the oblate earth surface. I prefer not to use Mapping Toolbox, but just core Matlab.
geoplot(lat,lon,'k-')
polyin = polyshape([lat',lon']);
refPoint = [refLat, refLon];
polyout = rotate(polyin, angleDeg, refPoint);
lat = [polyout.Vertices(:,1); polyout.Vertices(1,1)];
lon = [polyout.Vertices(:,2); polyout.Vertices(1,2)];
geoplot(lat,lon,'b--')
  1 件のコメント
Mike D.
Mike D. 2024 年 7 月 12 日 0:49
This rotate function works, but results are incorrect because the rotate(X,Y,...) assumes equal scale of X and Y. This is not true for latitude versus longitude. Change in latitude is not the same scale as change in longitude. The rotated object is incorrect. Here is my work around, which works accurately, but requires mapping toolbox functions:
p=geopolyshape(lats,lons);
[distm, azim] = distance(latRef, lonRef, lats, lons, wgs84Ellipsoid);
[latr, lonr] = reckon(latRef, lonRef, distm, azim+angle, wgs84Ellipsoid);
p2 = geopolyshape(latr, lonr);
geoplot(p2), or geoplot(latr, lonr)
Why can't a built-in function do this and make it easy. Or a toolbar, easy access button.

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

回答 (1 件)

Pujitha Narra
Pujitha Narra 2020 年 2 月 24 日
Hi Mike,
A rotation matrix might be of use to you. You can have a look at this: https://www.mathworks.com/matlabcentral/answers/296860-rotating-a-2d-shape
  1 件のコメント
Mike D.
Mike D. 2024 年 7 月 12 日 0:41
No, this doesn't work on a geoaxes plot because the fill function gives error: "Adding Cartesian plot to geoaxes is not supported." It probably also does not work because it assumes the scale of X and Y are equal. This is not true for geoaxes plots. Change in latitude is not equal to the same change in longitude. Calculations across oblate earth surface involve elliptical equations.

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

カテゴリ

Help Center および File ExchangeMap Display についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by