Is there a way to embed a colorbar in a webmap, or am I going about this the wrong way?
Mostra commenti meno recenti
I am trying to generate a heatmap for parameters we have collected vs. latitude/longitude on a USGS webmap. Here's my script so far...
nBins = 20;
lat = source.VSA_Results_Table.Latitude;
lon = source.VSA_Results_Table.Longitude;
pathloss = source.VSA_Results_Table.Path_Loss_dB;
binSpacing = (max(pathloss) - min(pathloss))/nBins;
binRanges = min(pathloss):binSpacing:max(pathloss)-binSpacing;
latlim = [min(lat), max(lat)];
lonlim = [min(lon), max(lon)];
[latlim, lonlim] = bufgeoquad(latlim, lonlim, .01, .01);
% Add an inf to binRanges to enclose the values above the last bin.
binRanges(end+1) = inf;
% histcdetermines which bin each speed value falls into.
[~, PathLossBins] = histc(pathloss, binRanges);
% Create a geographical shape vector, which stores the line segments as
% features.
s = geoshape();
lat = lat';
lon = lon';
PathLossBins = PathLossBins';
for k = 1:nBins
% Keep only the lat/lon values which match the current bin. Leave the
% rest as NaN, which are interpreted as breaks in the line segments.
latValid = nan(1, length(lat));
latValid(PathLossBins==k) = lat(PathLossBins==k);
lonValid = nan(1, length(lon));
lonValid(PathLossBins==k) = lon(PathLossBins==k);
% To make the path continuous despite being segmented into different
% colors, the lat/lon values that occur after transitioning from the
% current speed bin to another speed bin will need to be kept.
transitions = [diff(PathLossBins) 0];
insertionInd = find(PathLossBins==k & transitions~=0) + 1;
% Preallocate space for and insert the extra lat/lon values.
latSeg = zeros(1, length(latValid) + length(insertionInd));
latSeg(insertionInd + (0:length(insertionInd)-1)) = lat(insertionInd);
latSeg(~latSeg) = latValid;
lonSeg = zeros(1, length(lonValid) + length(insertionInd));
lonSeg(insertionInd + (0:length(insertionInd)-1)) = lon(insertionInd);
lonSeg(~lonSeg) = lonValid;
% Add the lat/lon segments to the geographic shape vector.
s(k) = geoshape(latSeg, lonSeg);
end
%generate the web map and route overlay
wm = webmap('USGS Imagery');
colors = hot(nBins);
wmlimits(latlim, lonlim)
%wmcenter(wm, 39.98, 105.26)
wmzoom(wm, 17)
wmline(s, 'Color', colors, 'Width', 7);
And the script works really well for generating the heatmap and underlying map. Unfortunately, if I just try adding a colorbar, using something like...
colors = hot(nBins);
colormap(colors);
c = colorbar
c.Limits = [round(binRanges(1), 2),round(binRanges(20), 2)]
c.Label.String = 'Bit Error Measurement (BER)'
wm = webmap('USGS Imagery');
wmlimits(latlim, lonlim)
%wmcenter(wm, 39.98, 105.26)
wmzoom(wm, 17)
wmline(s, 'Color', colors, 'Width', 7);
it'll generate a colorbar based on my specifications (mostly), but it's on a separate figure from my webmap. Is there a way to add a colorbar on the webmap image using soemthing like set(gcf,...)?
Looking at the mapdemos examples, it seems like webmaps might not be the best way forward. If it isn't, could someone show me where to start with putting my drive route lat/lon coordinates onto a USGS...shapefile(?) of the area, or pointing me to an example?
Thanks!
Risposta accettata
Più risposte (1)
Akshay Khadse
il 14 Set 2018
0 voti
As per my knowledge, 'webmap' opens a new browser window whereas 'colormap' cannot plot in the browser. Therefore, you are getting the color bar in a separate figure window.
However, currently there is no documented functionality to insert the 'webmap' into a 'panel' or a figure window. You could still dock the 'webmap'. The 'webmap' remembers the dock settings and will be docked the next time it is opened.
Please note that you cannot download the data and show it in a MATLAB Figure window using 'geoshow'.
1 Commento
Anna Paulson
il 17 Set 2018
Categorie
Scopri di più su Color and Styling in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!