The coastline is displayed incorrectly at 180° longitude when creating axesm-based map
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I used "axesm" to create a map and read the "landareas.shp" file to draw the land. When I modified the "origin" of the axesm-based map, the land at 180° longitude was split.

Is there any way to display correctly, except for setting "Edgecolor" to "none"?
figure;
ax1=axesm('MapProjection','eqdcylin','Frame','on','Grid','off', ...
'MLineLocation',60, 'PLineLocation',30, ...
'MeridianLabel','on','ParallelLabel','on', 'MLabelParallel','south', ...
'MapLatLimit',[-90 90],'MapLonLimit',[-180 180]);
ax1.Visible='off';
setm(ax1,'Origin',[0 180 0])
setm(ax1,'FLineWidth',1)
land = shaperead('landareas.shp','UseGeoCoords',true);
geoshow(land,'FaceColor',[0.8 0.8 0.8])
mlabels = findobj('Tag','MLabel');
mlabels(1).String = {'0°'};
mlabels(2).String = {'60°W'};
mlabels(3).String = {'120°W'};
mlabels(4).String = {'180°'};
mlabels(5).String = {'120°E'};
mlabels(6).String = {'60°E'};
mlabels(7).String = {'0°'};
plabels = findobj('Tag','PLabel');
plabels(1).String =' 90°N ';
plabels(2).String =' 60°N ';
plabels(3).String =' 30°N ';
plabels(4).String =' 0° ';
plabels(5).String =' 30°S ';
plabels(6).String =' 60°S ';
plabels(7).String =' 90°S ';
0 comentarios
Respuestas (1)
Ruchika Parag
el 3 de Jul. de 2025
Hi @yichen, this issue occurs because when 'Origin',[0 180 0] is set in axesm, the 180° meridian becomes the center of the map. The landareas.shp file defines longitude values in the range of −180° to 180°, so when features in the shapefile cross the dateline (±180°), they appear split due to the way the coordinates are stored and displayed.
To display these features correctly—without setting 'EdgeColor','none'—the longitude values must be adjusted to match the new map origin.
1. Shift longitude values relative to the new origin (e.g., 180°):
function shifted = shiftLonToCenter(shapes, centerLon)
shifted = shapes;
for k = 1:numel(shapes)
lon = shapes(k).Lon;
if ~isempty(lon)
shifted(k).Lon = wrapTo180(lon - centerLon);
end
end
end
2. Apply the shift to the land data:
land = shaperead('landareas.shp', 'UseGeoCoords', true);
landShifted = shiftLonToCenter(land, 180);
3. Display the adjusted land areas with the correct map origin:
figure;
ax = axesm('eqdcylin', 'Origin', [0 180 0], ...
'MapLatLimit', [-90 90], 'MapLonLimit', [-180 180], ...
'Frame', 'on', 'Grid', 'off');
setm(ax, 'FLineWidth', 1);
geoshow(landShifted, 'FaceColor', [0.8 0.8 0.8], 'EdgeColor', 'black');
This approach ensures that polygons crossing the dateline are properly displayed with the new origin, and that the edges remain visible and correctly connected.
0 comentarios
Ver también
Categorías
Más información sobre Map Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!