Can I have coloured points in geoshow like in a scatter plot?
조회 수: 46 (최근 30일)
이전 댓글 표시
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!
댓글 수: 1
답변 (1개)
Yue zhao
2022년 4월 19일
편집: Yue zhao
2022년 4월 19일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Purple에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!