1 Star 0 Fork 0

Admin/marx_DisPAT

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
geoeas2matlab.m 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
marx 提交于 2021-11-26 19:53 . v1
function Out = geoeas2matlab(datain,gridspecs);
% Transform GeoEas array into Matlab image
%
%% DESCRIPTION: geoeas2matlab.m
% Function to transform a SINGLE GoeEas-formatted raster (datain)
% i.e., a single column, to a MATLAB array that can be viewed using
% imagesc (in 2D) or slice (in 3D).
%
%% SYNTAX:
% Out = geoeas2matlab(datain,gridspecs);
%
%% INPUTS:
% datain = input GeoEas-formatted raster of dimensions:
% in 1D: (nx x 1)
% in 2D: (nx*ny x 1)
% in 3D: (nx*ny*nz x 1)
% gridspecs = (1 x ndim) vector with raster size
% in 1D: [nx]
% in 2D: [nx ny]
% in 3D: [nx ny nz]
%
%% OUTPUTS:
% Out = output MATLAB-image array of dimensions:
% in 1D: (nx x 1)
% in 2D: (ny x nx)
% in 3D: (ny x nx x nz)
%
%% NOTES:
% In 3D, z increases upwards
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SYNTAX:
% Out = geoeas2matlab(datain,gridspecs);
%% CREDITS:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Phaedon Kyriakidis %
% Department of Geography %
% University of California Santa Barbara %
% May 2005 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Some error checking
ndim = length(gridspecs);
if size(datain,2) ~= 1
error('datain must be a column vector');
end
if length(datain) ~= prod(gridspecs(:));
error('Length of datain incompatible with gridspecs');
end
% if any(gridspecs == 1)
% error('Found a 1 in gridspecs');
% end
%% Proceed according to dimensionality
switch ndim
case 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1D case
Out = datain;
case 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2D case
nx = gridspecs(1);
ny = gridspecs(2);
Tmp = reshape(datain,nx,ny);
Tmp = permute(Tmp, [2 1 3]);
Out = Tmp(ny:-1:1,:);
case 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3D case
nx = gridspecs(1);
ny = gridspecs(2);
nz = gridspecs(3);
Tmp = reshape(datain,nx,ny,nz);
Tmp = permute(Tmp, [2 1 3]);
Out = Tmp(ny:-1:1,:,:);
end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end switch ndim
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/marx_1_1307066363/marx_-dis-pat.git
git@gitee.com:marx_1_1307066363/marx_-dis-pat.git
marx_1_1307066363
marx_-dis-pat
marx_DisPAT
master

搜索帮助