source: issm/trunk-jpl/src/m/exp/segmentstobasin.m

Last change on this file was 22928, checked in by Eric.Larour, 7 years ago

CHG: new exp routine. + segmentstobasin: building block for meshing out of shapefile segments that concatenate into basin domains.

File size: 1.6 KB
Line 
1function segmentstobasin(basin,varargin)
2%SEGMENTSTOBASIN - read exp or shp files corresponding to the boundaries of a basin, and assemble
3% a basin file accordingly (by concatenating the segments). The segments might not be oriented
4% the right way, so the list of exp segment files given goes along booleans that determined whether
5% each segment should be inverted or not.
6%
7% Usage:
8% segmentstobasin(basinname,basin1,invert1,basin2,invert2,...)
9%
10% Example:
11% segmentstobasin('Antarctica.exp','Antarctica1.exp',0,'Antarctica2.shp',1); %we inverte the segments in Antarctica2.shp
12%
13% See also EXPREAD
14
15 %some checks
16 if exist(basin),
17 %choice=input(['A file ' basin ' already exists, do you want to modify it? (y/n)'],'s');
18 %if ~strcmpi(choice,'y'),
19 % disp('no modification done ... exiting');
20 % return;
21 %end
22 end
23
24 %go through the list of basins
25 if mod(length(varargin),2)~=0,
26 error('an even number of arguments should be provided after the basin name');
27 end
28
29 domain.x=[]; domain.y=[]; domain.nods=1;
30 for i=1:nargin/2,
31 expfile=varargin{(i-1)*2+1};
32 invert=varargin{(i-1)*2+2};
33 if isexp(expfile),
34 expstruct=expread(expfile,'invert',invert);
35 else
36 expstruct=shpread(expfile,'invert',invert);
37 end
38 domain.x=[domain.x;expstruct.x];
39 domain.y=[domain.y;expstruct.y];
40 domain.nods=domain.nods+length(expstruct.x);
41 end
42
43 domain.nods=domain.nods+1;
44 domain.x=[domain.x;domain.x(1)];
45 domain.y=[domain.y;domain.y(1)];
46 domain.Geometry='Polygon';
47
48 if isexp(basin),
49 expwrite(domain,basin);
50 else
51 shpwrite(domain,basin);
52 end
Note: See TracBrowser for help on using the repository browser.