How to create overlaping heatmap in geoplot

12 ビュー (過去 30 日間)
Jonathan
Jonathan 2024 年 4 月 4 日
コメント済み: Jonathan 2024 年 4 月 4 日
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.

採用された回答

Yash
Yash 2024 年 4 月 4 日
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 件のコメント
Jonathan
Jonathan 2024 年 4 月 4 日
Thanks! This is verry helpfull!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by