[16049] | 1 | function 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 |
|
---|
[17026] | 17 | expstruct=struct([]);
|
---|
[16049] | 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)=[];
|
---|
[17026] | 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);
|
---|
[16852] | 29 | elseif strcmpi(shp(i).Geometry,'Point'),
|
---|
[17026] | 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;
|
---|
[17346] | 39 | x(end)=x(1); y(end)=y(1);
|
---|
[17026] | 40 | expstruct(end+1).x=x;
|
---|
| 41 | expstruct(end).y=y;
|
---|
| 42 | expstruct(end).nods=length(x);
|
---|
| 43 | expstruct(end).density=1;
|
---|
| 44 | expstruct(end).closed=1;
|
---|
[16049] | 45 | end
|
---|
| 46 | end
|
---|
| 47 |
|
---|
[17026] | 48 | expwrite(expstruct,expfilename);
|
---|