필터 지우기
필터 지우기

geodensityplot of CONUS, Alaska, and Hawaii

조회 수: 5 (최근 30일)
Daniel Moran
Daniel Moran 2022년 6월 17일
답변: Yash 2023년 10월 13일
I am trying to create a geographical heat map aka geodensityplot with lattitude and longitude data and concentrations of metals imported from an excel file. I want to only show the continental united states with Alaska and Hawaii below.
How do I show those areas after creating the geodensityplot?
%% Import Excel sheet and assign variables to the column vectors.
% accomplished with ImportExcelMappingData.m
%% Map the USA including Alaska and Hawaii
% First create geodensity plot ie heatmap of mineral: Lithium
radiusInMeters = 50e3; % 50 km
dp = geodensityplot(LATITUDE,LONGITUDE,Li,'RadiusMode', 'manual', 'Radius',radiusInMeters, "FaceColor", 'interp');
colormap hot;
colorbar;
% Need to now take that generated geodensity plot and only show CONUS,
% Alaska and Hawaii
% I AM STUCK ON THIS PART!
% Read a shapefile, containing polygon shapes for each of the US states and the District of Columbia, into a geospatial table. Find the table rows for the conterminous USA, Alaska, and Hawaii.
states = readgeotable("usastatelo.shp");
rowConus = states.Name ~= "Hawaii" & states.Name ~= "Alaska";
rowAlaska = states.Name == "Alaska";
rowHawaii = states.Name == "Hawaii";
% Display each of the three regions on separate axes.
figure
ax = usamap('all');
set(ax,"Visible","off");
geoshow(ax(1),states(rowConus,:));
geoshow(ax(2),states(rowAlaska,:));
geoshow(ax(3),states(rowHawaii,:));
% Hide the frame
for k = 1:3
setm(ax(k),"Frame","off","Grid","off",...
"ParallelLabel","off","MeridianLabel","off");
showm(dp)
end
geoaxes(ax); % makes the Geographic axes object gx the current axes
basemap = geobasemap(ax); returns the basemap value for the geographic axes or chart specified by gx.
geobasemap(basemap) % sets the basemap of the current geographic axes or chart to the value specified by basemap.
% getm(gca,'MapProjection')

채택된 답변

Yash
Yash 2023년 10월 13일
Hi Daniel Moran,
I understand that you want to plot concentrations of metals with latitude and longitude data but only want to show continental US with Hawaii and Alaska. I am assuming that LATITUDE, LONGITUDE and Li are Nx1 arrays. Refer to the code below:
states = readgeotable("usastatelo.shp");
rowConus = states.Name ~= "Hawaii" & states.Name ~= "Alaska";
rowAlaska = states.Name == "Alaska";
rowHawaii = states.Name == "Hawaii";
% Display each of the three regions on separate axes.
figure
ax = usamap('all');
set(ax,"Visible","off");
geoshow(ax(1),states(rowConus,:));
geoshow(ax(2),states(rowAlaska,:));
geoshow(ax(3),states(rowHawaii,:));
% Hide the frame
for k = 1:3
setm(ax(k),"Frame","off","Grid","off",...
"ParallelLabel","off","MeridianLabel","off");
end
for i = 1:numel(Li)
geoshow(LATITUDE(i), LONGITUDE(i), 'DisplayType', 'point', 'Marker', 'o', 'MarkerFaceColor', 'red', 'MarkerSize', Li(i));
end
Refer to the following resources for discussion on plotting heatmap onto an existing mapping:
I hope this helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by