城市需求显示在地图上(附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

相关推荐
@陈小鱼20 小时前
MATLAB+Python:基于小样本卷积神经网络的 PPG 血压预测
人工智能·python·机器学习·matlab·脉搏波·血压·一维卷积神经网络
玖玥拾20 小时前
C# 语言进阶(十三)网络 DLL 库分层设计
服务器·开发语言·网络·网络协议·c#
2601_9498163520 小时前
C++内存对齐与结构体填充深度精讲:底层规则、内存裁剪、适配优化与工程避坑
开发语言·arm开发·c++
浩瀚地学20 小时前
【面试算法笔记】0105-数组-螺旋矩阵
java·开发语言·笔记·算法·面试
Geek-Chow20 小时前
Mobile App Certificate Pinning: Underlying Principle and a Swift Example
开发语言·ios·swift·安全架构
阿豪只会阿巴20 小时前
两小时快速入门 FastAPI--第一回
开发语言·python·fastapi
你怎么知道我是队长21 小时前
JavaScript 事件介绍
开发语言·前端·javascript
CodeStats21 小时前
【Linux IO】从文件描述符到硬件中断:Linux IO 系统底层完全拆解
java·linux·开发语言·io·socket
着迷不白21 小时前
Linux系统故障修复、日志管理与安全加固实战指南
开发语言·php
贺国亚21 小时前
A2A协议与Agent互操作-Task生命周期
开发语言·qt