Use m_ map draw evenly spaced lines

2 ビュー (過去 30 日間)
ke
ke 2022 年 12 月 14 日
回答済み: Nithin 2025 年 4 月 25 日
If an image is divided into 300×300 points, and the data of each point is known. The x-axis and y-axis coordinates of the image are longitude and latitude. How to correspond the points with longitude and latitude, and how to connect the points of the same data. Draw evenly spaced lines at 20 intervals.

回答 (1 件)

Nithin
Nithin 2025 年 4 月 25 日
Hi @ke,
To create the graph you described, you can use meshgrid to align your grid data with longitude and latitude, and m_contour to draw contours at regular intervals. Here’s a step-by-step outline of the process::
  • Generate longitude and lattitude grids
lon_min = ...; % e.g., 100
lon_max = ...; % e.g., 110
lat_min = ...; % e.g., 20
lat_max = ...; % e.g., 30
lon = linspace(lon_min, lon_max, 300);
lat = linspace(lat_min, lat_max, 300);
[Lon, Lat] = meshgrid(lon, lat); % size(Lon) = [300, 300]
  • Setup "m_map" projection
figure
m_proj('mercator', 'lon', [lon_min lon_max], 'lat', [lat_min lat_max]);
m_grid('box','fancy','tickdir','in');
hold on
  • Draw evenly spaced contour lines
interval = 20;
min_val = floor(min(data(:))/interval)*interval;
max_val = ceil(max(data(:))/interval)*interval;
v = min_val:interval:max_val;
[~, h] = m_contour(Lon, Lat, data, v, 'k'); % 'k' for black lines
clabel(_, h); % Optional: Add contour labels
Refer to the following documentations to know more about the functions used:

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by