在matlab中绘制出来是这样的,但是如果加到arcgis中,还需进一步
clc;clear;
lonlat = load('lonlat.mat');
trendy = load("trendy.mat");
% figure(1)
% set (gcf,'Position',[10,10,800,600], 'color','w')
% scatter(lonlat.r_lonlat(:,1),lonlat.r_lonlat(:,2),15,trendy.trendy,'s','filled');hold on
% %scatter(r_lonlat(wz1,1),r_lonlat(wz1,2),1,'ok')
% colormap(flipud(jet));
% caxis([-0.001 0.001]);axis off
% colorbar
% 一维数据
one_dimensional_data = trendy.trendy;
% 对应的经度和纬度
longitude = lonlat.r_lonlat(:,1);
maxlon = max(longitude);minlon = min(longitude);
latitude = lonlat.r_lonlat(:,2);
maxlat = max(latitude);minlat = min(latitude);
resolution = 0.25;
col_all = (maxlon-minlon)/resolution + 1;
row_all = (maxlat-minlat)/resolution + 1;
longitude_grid = (minlon:0.25:maxlon);
latitude_grid = (minlat:0.25:maxlat);
data_array = NaN(row_all, col_all);%data = NaN(rows, cols);
col = (longitude - minlon) / resolution + 1;
row = (latitude - minlat) / resolution + 1;
for i = 1:length(col)
% location = (row(i),col(i));
data_array(row(i),col(i)) = one_dimensional_data(i);
end
data_array = flipud(data_array);
% 定义输出GeoTIFF的文件名
output_filename = 'output.tif';
% 定义空间参考信息
R = georasterref('RasterSize', [size(data_array, 1), size(data_array, 2)], ...
'RasterInterpretation', 'cells', ...
'ColumnsStartFrom', 'north', ...
'LatitudeLimits', [min(latitude), max(latitude)], ...
'LongitudeLimits', [min(longitude), max(longitude)]);
% 创建GeoTIFF文件
geotiffwrite(output_filename, data_array, R);
disp('GeoTIFF文件已生成!');