Shape file overlay on basemap
1 次查看(过去 30 天)
显示 更早的评论
I am working on overlaying a shape file exported from a NOAA HYSPLIT model onto a base map. I can get the map to appear but I am strugging to get the traces from the shape file to appear on the map. Below is some of my code - I have tried different things, including a loop, but nothing has worked so far. I am not the best coder either, so this may be a simple fix. I attached the model output data here as well.
Thank you for your help!
figure
gx=geoaxes;
gx.MapCenterMode = "manual";
gx.MapCenter= [31.962299,-81.014213];
gx.Basemap = "streets-light";
gx.ZoomLevelMode= "manual";
gx.ZoomLevel=7;
hold on
geoplot(gx,ls.X,ls.Y)
hold off
% tried the loop below too but did not work
hold on
for p= 1:5
% geoplot(gx,traj1{1,p}.geopointshape.Latitude,traj1{1,p}.geopointshape.Longitude)
geoplot(gx,ls(p).X,ls(p).Y)
end
hold off
0 个评论
回答(1 个)
Voss
2025-3-6
unzip('gis_110139.zip')
figure
gx=geoaxes;
gx.MapCenterMode = "manual";
gx.MapCenter= [31.962299,-81.014213];
gx.Basemap = "streets-light";
gx.ZoomLevelMode= "manual";
gx.ZoomLevel=7;
hold on
S = shaperead('GIS_traj01_110139.shp');
geoplot(gx,[S.Y],[S.X])
2 个评论
Voss
2025-3-9
You're welcome!
The problem is that the traces need to be separated from each other and plotted separately. In the code below, I address that by assuming that the 'id' field of the shape file data can be used to identify the separate traces (e.g., points with id 1000-1999 belong to trace 1, points 2000-2999 belong to trace 2, etc.).
unzip('gis_110139.zip')
figure
gx=geoaxes;
gx.MapCenterMode = "manual";
gx.MapCenter= [31.962299,-81.014213];
gx.Basemap = "streets-light";
gx.ZoomLevelMode= "manual";
gx.ZoomLevel=4; % changed to show more complete traces
hold on
S = shaperead('GIS_traj01_110139.shp');
[G,GID] = findgroups(floor([S.id]/1000));
for ii = 1:numel(GID)
idx = G == ii;
geoplot(gx,[S(idx).Y],[S(idx).X])
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!