Shapefile not overlapping perfectly over pcolor plot
显示 更早的评论
I am trying to plot a pcolor plot for Sea surface temperature data set and to represent the coastaline in the plot i have downloadwed global coastline shapefile and when i am using geoshow to read and overlay on the pcolor plot it is not matching perfectly 

6 个评论
Umar
2024-7-24
Hi Muskula,
Since you have not shared data and code, the only conclusion I can draw is alignment issues which can occur due to differences in coordinate systems or projections. Ensure that both the coastline shapefile and the pcolor plot are using the same coordinate system. You may need to reproject one of the datasets to match the other.
Muskula
2024-7-25
Umar
2024-7-25
编辑:Walter Roberson
2024-7-25
Hi Muskula,
Here is an updated version of the code snippet provided by you with some modifications for better alignment:
[Y, X] = meshgrid(linspace(-179.750, 179.750, 720), linspace(89.750, -89.750, 360));
h1 = pcolor(Y, X, Data);
hold on
coastline = shaperead("ne_50m_coastline.shp");
geoshow(coastline, 'DisplayType', 'line', 'EdgeColor', [0 0 0]);
In this updated code snippet, you can read the coastline shapefile using shaperead to obtain the coastline data, use geoshow with 'DisplayType', 'line' to overlay the coastline as a line on the pcolor plot, Adjusting the properties of the coastline display as needed for better alignment. By following these steps and ensuring proper coordinate system alignment and scaling, you should be able to overlay the coastline accurately on the pcolor plot. Please let me know if this helps resolve your issue.
Muskula
2024-7-27
Umar
2024-7-27
Hi Muskula,
Like I said in my earlier comments, “ Since you have not shared data and code, the only conclusion I can draw is alignment issues which can occur due to differences in coordinate systems or projections”. Glad to know your problem is resolved. So, this answers your question.
回答(1 个)
Jacob Halbrooks
2026-11-30,15:31
0 个投票
Based on the discussion in the comments, it appears that the issue is caused by a mismatch in how the two datasets are spatially referenced. A simple offset could result from a uniform shift in the data, but the increasing distortion toward the poles suggests that the two datasets are more likely using different coordinate reference systems (CRS).
Starting in R2026a, you can use geopcolor to create a pseudocolor raster plot from raster data with coordinates in any supported geographic or projected CRS. You can create the plot in a geographic axes or a map axes, and the function displays the data in the map projection of the axes. Unlike pcolor, which plots coordinates as plain x and y values, geopcolor uses the CRS of the data, so the raster lines up with other data plotted in the same axes.
类别
在 帮助中心 和 File Exchange 中查找有关 Vector and Raster Map Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!