How to create overlaping heatmap in geoplot

13 vues (au cours des 30 derniers jours)
Jonathan
Jonathan le 4 Avr 2024
Commenté : Jonathan le 4 Avr 2024
Hello!
So I have a matlab code that plots geo lat and lon points and using geodensityplot, each point have a raduis of 7 meter. My question is, how can I makes the plotted density discrete, and when there circle are overlaping, the overlapping part has a different color? Btw, I dont have the mapping toolbox.

Réponse acceptée

Yash
Yash le 4 Avr 2024
To achieve a discrete density plot with overlapping circles of different colors, you can use the scatter function in MATLAB. This code generates random latitudes and longitudes and plots them as discrete circles with a radius of 7 meters. The circles that overlap will have different colors. Note that the distance function used here is part of the Mapping Toolbox, so you may need to find an alternative implementation if you don't have the toolbox. Here's an example code snippet:
% Generate random latitudes and longitudes
lat = rand(100, 1) * 180 - 90;
lon = rand(100, 1) * 360 - 180;
radius = 7;
figure;
for i = 1:numel(lat)
% Calculate the distance between each point and all other points
distances = distance(lat(i), lon(i), lat, lon);
% Find the indices of points within the radius
indices = find(distances <= radius);
% Plot the points within the radius with different colors
scatter(lon(indices), lat(indices), 'filled');
hold on;
end
xlim([-180 180]);
ylim([-90 90]);
% Set the aspect ratio to equal
daspect([1 1 1]);
grid on;
colorbar;
title('Discrete Density Plot');
xlabel('Longitude');
ylabel('Latitude');
Hope this helps!
  1 commentaire
Jonathan
Jonathan le 4 Avr 2024
Thanks! This is verry helpfull!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Geographic Plots dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by