Get Point data from geoaxes
10 views (last 30 days)
Show older comments
Hello All,
I'm trying to find a way to get point data from a Matlab basemap with the mouse. I have a workaround solution, though I find it very stupid to have to do it this way. The issue I'm facing is that ginput, getpts, inputm, and custom matlab scripts that I've found will not cooperate with "geoaxes". I've tried GinputC,ginput_ax, ginputB, and am working on my own rendition to solve the issue. The reason I'm using the basemap is it provides me the service offline of zooming, panning, and viewing data on the map. I'd rather not recreate these functions and increasing resolution with zoom on my own.
Base Script (includes a snipit of Data Manager script)
close all
clear
clc
Color = [.5 .5 .5]
Test = Manager();
Test.f = figure('Color',Color,'Position', [360 500 1500 700]);
Test.plot.Axes = geoaxes('Parent',Test.f,...
'Units','pixels',...
'Position', [60 85 1050 600]);
geobasemap(Test.plot.Axes,'colorterrain');
movegui(Test.f,'center');
%% SEPARATE SCRIPT FOR DATA MANAGEMENT
classdef Manager < handle
properties
f;
plot;
end
end
My current workaround (really dumb), Is to "getframe" and "frame2im" the entire figure, Create another figure of the exact same size over top the first, Give figure(2) axes that are the entire figure, and imshow "Figure 1" essentially in Figure 2. Then, I can use any ginput script I like to get the x,y position. Compare that to the limits of the "geoaxes" and convert the pixel x,y to Lat,Long. Delete Figure 2 when done, and plot the saved points back in figure 1.
pause(2)
F = getframe(Test.f);
[X Map] = frame2im(F);
Jack = figure('Color',Color,'Position', [360 500 1500 700]);
JackAxes = axes('Units','normalized','Position',[0 0 1 1])
movegui(Jack,'center')
imshow(X,'Parent',JackAxes);
[x,y] = ginput(4);
delete(Jack);
0 Comments
Answers (1)
Amy Haskins
on 28 Mar 2019
Hi Benjamin,
Support for using ginput with a geoaxes has been added in R2019a which just came out.
Amy
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!