地图上做标注

如何使用matlab做标注?这里有一些小技巧。
这里写图片描述

这里写图片描述

  • 编写mercatorProjection.m子函数如下:
function [x,y] = mercatorProjection(lon, lat, width, height)
    x = mod((lon+180)*width/360, width) ;
    y = height/2 - log(tan((lat+90)*pi/360))*width/(2*pi);
end
  • 主函数如下

clc
clear

%# GPS positions (latitude,longitude) of some markers
data=[40.712700 -74.005900;
    39.913900 116.392000];
labels = {
    '用户A'
    '用户B'
};

%# world map in Mercator projection
fname = 'picture.jpg';
img = imread(fname);
[imgH,imgW,~] = size(img);

%# Mercator projection
[x,y] = mercatorProjection(data(:,2), data(:,1), imgW, imgH);

%# plot markers on map
imshow(img, 'InitialMag',100, 'Border','tight'), hold on
plot(x,y, 'y.', 'MarkerSize',20, 'LineWidth',3)
text(x, y, labels, 'Color','w', 'VerticalAlign','bottom', 'HorizontalAlign','right')
line(x,y, 'LineStyle', '--', 'LineWidth', 2, 'Color', 'r');hold off
******matlab要运行程序要保证程序在工作目录下,或者打开函数当前所在目录皆可设置工作目录要具体到文件夹******
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陆嵩

有打赏才有动力,你懂的。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值