-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshapeLoad.m
37 lines (31 loc) · 1012 Bytes
/
shapeLoad.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
%
% Function to load the polygons in a shapefile and return them as a cell
% array of polygon objects. Nothing is returned the shapefile contains
% points or lines.
%
function poly = shapeLoad()
poly = {};
filterSpec = {'*.shp','*.shp - Shapefile containing polygons to evaluate.'};
[fName, dirPath, ~] = uigetfile(filterSpec,'Load Shapefile',...
'MultiSelect','off');
% Readem
if ~isnumeric(dirPath) && ~isnumeric(fName)
fPath = [dirPath, fName];
if exist(fPath,'file')
try
s = shaperead(fPath);
catch
% If file is invalid.
return
end
% Make a cell array of polygon objects.
counter = 0;
for i = 1:numel(s)
if strcmpi(s(1).Geometry,'polygon')
counter = counter + 1;
poly{counter} = polyObj(s(i));
end
end
end
end
end