Geoscatter marker shape as a variable

조회 수: 22 (최근 30일)
Raffaello Nardin
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
Simon Chan 2023년 2월 24일
How about this? Put them into categorical format.
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
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
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 CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by