# Geoscatter marker shape as a variable

52 ビュー (過去 30 日間)
Raffaello Nardin 2023 年 2 月 24 日
コメント済み: Simon Chan 2023 年 2 月 24 日
I'm mapping some sampling sites over a small map (approx 100km *100km in size), I'm using geoscatter because it feels like it's the only viable option on Matlab on the scale I need (still struggling to get a decent basemap without paying google for an API key but that's another story), since each sampling site is characterized by a different type of soil, I also need to take into account for that variable as well as the position. Is there a way to make the marker shape (not color or size they're misleading).
I admit I don't have much experience in matlab, but geoscatter seems easy enough, except I struggle to understand how to make the marker shape change
lat = [42.5, 42.56, 43.67, 42.29, 42.97, 43.98];
long = [11.43, 10.98, 11.7, 10.38, 10.67, 10.98];
type = ['A', 'B', 'C', 'A', 'B', 'B'];
geoscatter(lat, long,10,type,'xos')
geobasemap('topographic')
Of course this doesn't work, but I am struggling to see a solution that doesn't involve creating n geoscatter plots one on top of the other by manually grouping all the data together (so making a latA, longA plot, a latA, longB etc...)... which seems viable for this small dummy dataset, but considering the number of samples is in the thousands with a 30 or so type of terrain to map, you get why I wanted to find something more automated.
Any suggestions?

サインインしてコメントする。

### 回答 (1 件)

Simon Chan 2023 年 2 月 24 日
lat = [42.5, 42.56, 43.67, 42.29, 42.97, 43.98];
long = [11.43, 10.98, 11.7, 10.38, 10.67, 10.98];
type = categorical({'A', 'B', 'C', 'A', 'B', 'B'}); % Use categorical
ntype = categories(type);
markershape = ["+","^","o"];
gx = geoaxes;
hold on;
for k=1:length(ntype)
idx = type==ntype(k);
geoscatter(gx,lat(idx), long(idx),markershape(k),'LineWidth',5);
end
geobasemap('topographic')
##### 2 件のコメントなしを表示なしを非表示
Raffaello Nardin 2023 年 2 月 24 日
It works, thank you a lot! I assume using the same logic I can create a vector of colors and have each one have a more readable color as well?
Simon Chan 2023 年 2 月 24 日
Yes, see the example below including marker shape, marker size (called LineWidth in geoscatter) and color as well.
lat = [42.5, 42.56, 43.67, 42.29, 42.97, 43.98];
long = [11.43, 10.98, 11.7, 10.38, 10.67, 10.98];
type = categorical({'A', 'B', 'C', 'A', 'B', 'B'});
ntype = categories(type);
markershape = ["+","^","o"]; % Marker shape
markersize = [15 10 5]; % Size of marker, it is called LineWidth in geoscatter
color =["r","m","g"]; % Color of marker
gx = geoaxes;
hold on;
for k=1:length(ntype)
idx = type==ntype(k);
geoscatter(gx,lat(idx), long(idx),color(k),markershape(k),'LineWidth',markersize(k));
end
geobasemap('topographic');

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by