How to create overlaping heatmap in geoplot
조회 수: 12 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!