城市需求显示在地图上(附MATLAB程序)

我们显示很多城市信息时, 有时候需要把各地人口数量, 各地城市对某种货物的需求量呈现到地图上, 可以用以下代码实现:

程序结果:

% 画中国地图

clc;close all;clear all;

%%曲面拟合

warning off;%禁止显示警告信息

% load lonlatdata.mat;

lonlatdata=xlsread('工作簿1.xls','D2:F301');%载入xls的数据

x=lonlatdata(:,1);%载入经度

y=lonlatdata(:,2);%载入纬度

z=lonlatdata(:,3);%载入需求

%设置拟合参数

xmin=min(lonlatdata(:,1));

xmax=max(lonlatdata(:,1));

ymin=min(lonlatdata(:,2));

ymax=max(lonlatdata(:,2));

xstep=(xmax-xmin)/100;

ystep=(ymax-ymin)/100;

gx=xmin:xstep:xmax;

gy=ymin:ystep:ymax;

g=gridfit(x,y,z,gx,gy);

%%----------------数据拟合开始--------------------

position01=-100000;%用于调整Z轴比例,绝对值越小,曲面越曲

%%----------------数据拟合结束--------------------

figure;

colormap(hot(256));

mesh(gx,gy,g);

camlight right;

lighting phong;

shading interp

hold on;

map_path = shaperead('bou2_4l.shp');% 省级行政区划

map_X = map_path(:).X;

map_Y = map_path(:).Y;

ax=length(map_X);

ay=length(map_Y);

map_Z=ones(ax,1)*(position01);

plot3(map_X,map_Y,map_Z);

hold on;

map_path = shaperead('diquJie_polyline.shp');% 地级行政区划

map_X = map_path(:).X;

map_Y = map_path(:).Y;

ax=length(map_X);

ay=length(map_Y);

map_Z=ones(ax,1)*(position01);

plot3(map_X,map_Y,map_Z);

hold on;

%%画城市点

x=lonlatdata(:,1);

y=lonlatdata(:,2);

acity=length(x);

z0=ones(acity,1)*(position01);

plot3(x,y,z0,'r.');

hold on;

%画城市线

for i=1:acity

plot3(x(i),x(i),y(i),y(i),z0(i),z(i),'r:');

hold on;

end

xlabel('经度');

ylabel('纬度');

zlabel('需求(元)');

title('需求拟合');

完整代码见: https://download.csdn.net/download/corn1949/88774936

需要讨论可加Q1579325979

相关推荐
水桶学习吧_43 分钟前
基于MATLAB的圆锥滚子轴承故障诊断仿真
matlab·故障诊断·圆锥滚子轴承
利威尔xu1 小时前
Go channel 关闭 3 个 panic:向已关闭 channel 发送,服务当场崩溃
开发语言·后端·golang·并发编程·channel
山楂树の1 小时前
Java BigDecimal笔记
java·开发语言
Java展博5 小时前
[Go 后端转场] 从 try-catch 到 if err != nil:写惯 Java 的人第一次上手最别扭的 4 件事
java·开发语言·golang
SEO_juper5 小时前
Node.js 全站 SEO 体检报告生成器:一次查完标题、描述、canonical、H1、图片
开发语言·前端·node.js·html·bash
风落青芜6 小时前
数据结构:堆的概念与实现
c语言·开发语言·数据结构·算法
H H.9 小时前
Java企业级开发:从框架到工程化实战
java·开发语言·经验分享·其他·课程设计
吃我一窝jio20 小时前
Python与Go线程模型深度对比
java·开发语言·python
eggwyw20 小时前
C++ union 的一种妙用法
开发语言·c++
starzy19901 天前
深入理解Scala隐式函数:自动类型转换
开发语言·后端·scala