# Geoscatter marker shape as a variable

27 views (last 30 days)
Raffaello Nardin on 24 Feb 2023
Commented: Simon Chan on 24 Feb 2023
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?
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Answers (1)

Simon Chan on 24 Feb 2023
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 CommentsShow NoneHide None
Raffaello Nardin on 24 Feb 2023
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 on 24 Feb 2023
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');

Sign in to comment.

### Categories

Find more on Geographic Plots in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!