How to plot patch on geoaxis?

13 visualizaciones (últimos 30 días)
Bradley
Bradley el 19 de Jun. de 2025
Respondida: Rahul el 23 de Jun. de 2025
When I plot geographic data like position data I have a nice base map that I like to use, its black and white and the land border is blue. Ive used it for all my other products and would like to continue using it.
I have depth data from a vehicle I ran and I used patch to color the lat and long points as depth. When I try to add this patch function to a geoplot it tells me geoplot doesnt support patch. Ill attach some code below so you can see what im talking about but is there an easier way to plot depth data like what I have on a geoplot? Thanks!
here how I normally plot position data with my base map:
land = readgeotable("tl_2019_us_coastline.shp");
gx = geoaxes;
geoplot(gx,land)
hold on
geoplot(gx, SpeedLat, SpeedLong)
This works well and I like the look of it. Heres how I plot my patch function:
depthD1(end) = NaN;
a = depthD1;
patch(LongD1, LatD1, a, 'EdgeColor', 'interp', 'LineWidth', 9)
This looks pretty nice as well, however it doesnt have any sort of geographical context. Is there a way to plot patch data on a geoplot or is there another function im not aware of? Thanks!
  1 comentario
Abhishek
Abhishek el 23 de Jun. de 2025
Hi @Bradley, If your depth data is gridded (or can be interpolated to a grid), you can use 'geoshow'.

Iniciar sesión para comentar.

Respuestas (1)

Rahul
Rahul el 23 de Jun. de 2025
Hi Bradley,
I understand that you are trying to visualize depth data on top of your existing geographic basemap in MATLAB, and are encountering issues when attempting to use the 'patch' function with 'geoplot'.
This issue can occur because 'geoaxes' and the 'geoplot' function do not support general graphics objects like 'patch'. Since the goal is to overlay depth information using color on a geographic map, a good alternative could be to use the 'geoscatter' function. This should allows us to plot each (latitude, longitude) point and color it based on a third variable, in this case, depth.
To achieve the same in MATLAB, you can try replacing the 'patch' plotting section with the following code snippet:
gx = geoaxes;
geobasemap(gx, 'grayterrain'); % You can use your preferred black & white basemap
hold on;
% Plot depth data using colored scatter points
geoscatter(gx, LatD1, LongD1, 30, depthD1, 'filled');
colorbar;
title('Depth Visualized on Base Map Using geoscatter');
The 'geoscatter' function supports colored markers that can be mapped to depth values.
This approach maintains the geographic context and preferred base map while visually encoding depth information using color.
Moreover, Axis labels are not required with 'geoaxes', as it displays latitude and longitude automatically.
To know more about the usage of various functions and parameters mentioned in the previous code snippet, you can refer to the following docuementation links:
Hope this helps!

Categorías

Más información sobre Geographic Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by