MATLAB: ButtonDownFcn return map coordinates

Mapping Toolbox

Is there a way to get the map coordinates from a geotiff image using graphics object callback functions for a mouse click location?

Best Answer

Obtaining the coordinates from a geotiff image is possible through the axes object properties. The 'CurrentPoint' property contains the axes points of the most recent mouse click on the axes. An example is provided below.
You can run this example by copying the code below into a script and hitting 'Run'.
figure
im = mapshow('boston.tif')
ax = gca;
im.PickableParts = 'none';
ax.ButtonDownFcn = @mouseClick;
function mouseClick(~,~)
get(gca,'CurrentPoint')
end