Created Shape file from matrices

10 views (last 30 days)
Dear all,
i would like to convert a matlab file into a shape file. I wrote the code below, however an error message is still appearing (sea below), does someone have any ideas how to solve it, pelase?
Error message:
error using shapewrite
Expected input number 1, S, to be a vector.
Error in shapewrite>parseInputs (line 667)
validateattributes(S, ...
Error in shapewrite (line 82)
[S, basename, dbfspec] = parseInputs(varargin{:});
Error in average_current (line 137)
shapewrite(Data, 'EBB_current.shp');
%% Convert to shape file
clear all
close all
clc
% assign the path to your working directory:
cd ('E:\publi\Waiting-room\bird_swnasea\Velocity_file\');
file = 'Average_EBB.mat';
load(file,'U','V');
Data = struct([]) ; % initilaize structure
for i = 1:141 % number lines of matrices U and V
for j = 1:161 %number of column of matrices U and V
Data(i,j).Geometry = 'Polygon' ;
Data(i,j).X = U(i,j) ; % latitude
Data(i,j).Y = V(i,j); % longitude
Data(i,j).Name = 'EBB' ; % some random attribute/ name
end
end
shapewrite(Data, 'EBB_current.shp');

Accepted Answer

Walter Roberson
Walter Roberson on 29 Jul 2022
shapewrite(Data(:), 'EBB_current.shp');

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!