source: issm/trunk-jpl/src/m/shp/Shp2Exp.m@ 17026

Last change on this file since 17026 was 17026, checked in by cborstad, 11 years ago

CHG: added support for line shapefiles

File size: 1.2 KB
Line 
1function Shp2Exp(expfilename,shapefilename)
2%SHP2EXP- transform shape file to Argus .exp file
3%
4% Usage:
5% Shp2Exp(expfilename,shapefilename);
6%
7% Example:
8% Shp2Exp('Domain.exp','Domain.shp');
9%
10% See also EXPMASTER, EXPDOC
11
12 if ~exist(shapefilename,'file'),
13 error(['Shapefile ' shapefilename ' does not exist']);
14 end
15 shp=shaperead(shapefilename);
16
17 expstruct=struct([]);
18 for i=1:length(shp),
19 if strcmpi(shp(i).Geometry,'Polygon'),
20 x=shp(i).X; y=shp(i).Y;
21 ids=find(isnan(x));
22 x(ids)=[]; y(ids)=[];
23 expstruct(end+1).x=x;
24 expstruct(end).y=y;
25 expstruct(end).nods=length(x);
26 expstruct(end).density=1;
27 expstruct(end).closed=1;
28 expstruct(end).name=num2str(shp(i).id);
29 elseif strcmpi(shp(i).Geometry,'Point'),
30 x=shp(i).X; y=shp(i).Y;
31 expstruct(end+1).x=x;
32 expstruct(end).y=y;
33 expstruct(end).nods=length(x);
34 expstruct(end).density=1;
35 expstruct(end).closed=1;
36 %exp(end).name=num2str(shp(i).id);
37 elseif strcmpi(shp(i).Geometry,'Line'),
38 x=shp(i).X; y=shp(i).Y;
39 expstruct(end+1).x=x;
40 expstruct(end).y=y;
41 expstruct.x(end)=x(1);
42 expstruct.y(end)=y(1);
43 expstruct(end).nods=length(x);
44 expstruct(end).density=1;
45 expstruct(end).closed=1;
46 end
47 end
48
49 expwrite(expstruct,expfilename);
Note: See TracBrowser for help on using the repository browser.