Borrar filtros
Borrar filtros

Can I have coloured points in geoshow like in a scatter plot?

42 visualizaciones (últimos 30 días)
Antje
Antje el 28 de Sept. de 2012
Editada: Yue zhao el 19 de Abr. de 2022
Hi all,
I want to plot DEM data with lat, lon and H as points with geoshow. The color shoud represent the elevation H like you can do it using scatter:
  • scatter(lon, lat, 5, H)
Is it possible to do the same in geoshow without gridding? I can plot the coordinates as points with a certain colour, but how can I use H as colour?
  • worldmap(rangeLat,rangeLon); geoshow(green, 'FaceColor', 'k','LineWidth',1);
  • geoshow(lat,lon,'DisplayType','point','MarkerEdgeColor','r','Marker', '.');
Thanks for your help!

Respuestas (1)

Yue zhao
Yue zhao el 19 de Abr. de 2022
Editada: Yue zhao el 19 de Abr. de 2022
I know this reply is a "LITTLE" late, but the question is common. Hope the reply would help future readers.
Yes, I find a way to do so. The main point in my answer is to use "makesymbolspec".
You can find how to use "makesymbolspec" in cases of lines in the following official tutorial: https://www.mathworks.com/help/map/ref/makesymbolspec.html
1) As for points, it is similar. But I assume you don't have a geospatial table for your points. You need to create one so that you could use "makesymbolspec" and "geoshow" more smoothly. It is very convenient and easy.
% I assume your lat, lon, H are all N-by-1 column vectors.
Shape = geopointshape(lat,lon);
% geopointshape is for creating points in the geospatial table
% lat,lon contains position for your data points
myMap = table(Shape,H);
% The geospatial table is created.
You can find the official document on "geospatial" here: https://www.mathworks.com/help/map/create-geospatial-tables.html
2) Then you can set points colors based on the "H" attribute in the geospatial table:
pointColor = makesymbolspec('Point',{'H',[min(H) max(H)],'Marker','.','MarkerEdgeColor',turbo});
% you can relax the limit [low_val high_val] a little bit if it helps, and change "caxis" accordingly.
% I used turbo here, you can change the colormap to many other types:
% https://www.mathworks.com/help/matlab/ref/colormap.html
% The 'H',[min(H) max(H)] pair is where you can set color based on required attribute.
% If you use '.' as the Marker, you have to use 'MarkerEdgeColor' not 'Color'.
3) Then you can show the points to your map:
geoshow(myMap,'DisplayType','Point','SymbolSpec',pointColor);
caxis([min(H) max(H)]);
colorbar;
This is what I produce for my dataset:
* For my case, "usamap" and "plotm" don't need the Mapping Toolbox, while "geoshow" does.

Categorías

Más información sobre Purple 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!

Translated by