Markers in geoplot map for different variables

15 次查看(过去 30 天)
Hello,
I have processed the data and tried to plot 5 different bands (Band 1:5) against gps data on geoplot. However, I was not sure how to classify among bands on the plot, so I concatenate all the 5 bands (5301x1 cell each) data into one array (26505x1 cell). Then after normalising the data (removing the unassigned/empty values), I plotted the data against Lat and Long which were respective to the reading.
Now, I want to know which reading belongs to which band at what location. Would it be possible to classify from the map by putting markers by selecting specific number of rows to segregate 5 different bands data?
Here's the part ot the script relevant to plot which I tried:
datavector_normalized = (combined_output - scale_bounds(1))/scale_diff;
datavector_normalized(datavector_normalized < 0) = 0;
datavector_normalized(datavector_normalized > 1) = 1;
datavector_normalized(isnan(datavector_normalized)) = [];
map_colors = colormap(jet(scale_diff+1));
mapval = ceil((datavector_normalized)*scale_diff);
for n = 1:length(datavector_normalized)
if ((output_longitude(n)~=0) && (output_latitude(n)~=0))
mycolor(n,:) = map_colors(mapval(n)+1,:);
geoplot(output_latitude(n), output_longitude(n), ...
'Marker', 'o', 'Color', mycolor(n,:), ...
'MarkerEdgeColor', mycolor(n,:), ...
'MarkerFaceColor', mycolor(n,:))
title('Geoplot for 5 bands)')
end
end
While it may be a little vague but I hope that I am making some sense with the query.
Please let me know if I can seperate the data with the markers on the map to classify among bands. or is there is any better way to do so.
Looking forward to the suggestions.
Thanks!

回答(1 个)

Sanchari
Sanchari 2024-5-3
Hello Abhishek,
To classify and visualize the data from 5 different bands on a geoplot with distinct markers or colors, you can modify your approach to include a categorical variable that represents each band. This way, you can easily distinguish between the bands on the plot. Here’s a conceptual step-by-step approach:
Step 1: Preparing your Data
First, ensure you have latitude, longitude, normalized data, and a band identifier for each reading. If you've concatenated data from 5 bands into one array, you should also create an array that identifies the band for each reading.
For example,
% Assuming you have 5301 readings for each band
num_readings_per_band = 5301;
band_identifiers = repelem(1:5, num_readings_per_band)';
Step 2: Plotting with Classification
You can use different markers or colors for each band. Here's how you could modify your script to incorporate band classification:
% Assuming output_latitude, output_longitude are your coordinates
% datavector_normalized is your normalized data
% band_identifiers is an array that identifies the band of each reading
% Define colors or markers for each band
colors = lines(5); % Generates 5 distinct colors
% Alternatively, you can define custom colors or use markers for each band
figure; hold on; % Open a new figure and hold it for multiple plots
title('Geoplot for 5 Bands');
for band = 1:5
% Find indices for the current band
idx = find(band_identifiers == band);
% Extract data for the current band
lat_band = output_latitude(idx);
lon_band = output_longitude(idx);
color_band = colors(band, :); % Color for the current band
% Plot
geoscatter(lat_band, lon_band, 20, color_band, 'o', 'filled'); % Modify marker size and style as needed
end
hold off;
legend('Band 1', 'Band 2', 'Band 3', 'Band 4', 'Band 5', 'Location', 'best');
In this code:
  1. The “band_identifiers” array is used to determine which readings belong to which band. This is crucial for classification.
  2. The script loops through each band, finds the readings belonging to that band, and plots them with a distinct colour or marker.
  3. “geoscatter” has been used here instead of “geoplot” as it’s more suited for plotting individual data points with specific colors or markers.
  4. Adding a “legend” helps in distinguishing between the different bands.
When plotting many points, consider plotting all points of the same band in a single call to “geoscatter” or “geoplot” instead of plotting each point individually. This can significantly improve the performance.
Also ensure that NaN values or zeros in the latitude and longitude data has been correctly handled to avoid plotting issues.
Please refer to the following links to know further about related queries:
  1. Geoscatter (MathWorks documentation): https://www.mathworks.com/help/matlab/ref/geoscatter.html?searchHighlight=geoscatter&s_tid=srchtitle_support_results_1_geoscatter
  2. Geoplot (MathWorks documentation): https://www.mathworks.com/help/matlab/ref/geoplot.html?searchHighlight=geoplot&s_tid=srchtitle_support_results_1_geoplot
  3. Geoplot to plot points, lines, and polygons on map since R2022a (MathWorks documentation): https://www.mathworks.com/help/map/ref/geopointshape.geoplot.html?searchHighlight=geoplot&s_tid=srchtitle_support_results_2_geoplot
  4. Plot markers on map (ML Answer): https://www.mathworks.com/support/search.html/answers/2024182-plot-markers-on-map.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:matlab/geographic-plots&page=1
  5. Plotting a circle using geoplot (ML Answer): https://www.mathworks.com/support/search.html/answers/1948003-plotting-a-circle-using-geoplot.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:matlab/geographic-plots&page=1
  6. Geoplot/geobubble with hold on (ML Answer): https://www.mathworks.com/support/search.html/answers/1447149-how-to-use-geoplot-geobubble-with-hold-on.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:matlab/geographic-plots&page=1
  7. Geoscatter marker shape as a variable (ML Answer): https://www.mathworks.com/support/search.html/answers/1918165-geoscatter-marker-shape-as-a-variable.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:matlab/geographic-plots&page=1
Hope this helps!

类别

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