Last change
on this file since 21372 was 21372, checked in by Eric.Larour, 8 years ago |
CHG: better identification of line vs polygon
|
File size:
934 bytes
|
Line | |
---|
1 | function exp2shp(shapefilename,expfilename,geometry)
|
---|
2 | %SHPWRITE - write a shape file from a contour structure
|
---|
3 | %
|
---|
4 | % Usage:
|
---|
5 | % exp2shp(shapefilename,expfilename,geometry)
|
---|
6 | %
|
---|
7 | % Example:
|
---|
8 | % exp2shp('domainoutline.shp','domainoutline.exp')
|
---|
9 | % exp2shp('domainoutline.shp','domainoutline.exp','Polygon')
|
---|
10 | % exp2shp('massfluxgate.shp','massfluxgate.exp','Line')
|
---|
11 | %
|
---|
12 | % See also SHPREAD, SHPWRITE, SHP2EXP
|
---|
13 |
|
---|
14 | shp=expread(expfilename);
|
---|
15 |
|
---|
16 | %initialize number of profile
|
---|
17 | count=0;
|
---|
18 |
|
---|
19 | contours=struct([]);
|
---|
20 | for i=1:length(shp),
|
---|
21 | if nargin < 3
|
---|
22 | if length(shp(1).x) == 1
|
---|
23 | geometry = 'Point';
|
---|
24 | elseif length(shp(1).x) < 3
|
---|
25 | geometry = 'Line';
|
---|
26 | else
|
---|
27 | if (shp(1).x(end)==shp(1).x(1) && shp(1).y(end)==shp(1).y(1)),
|
---|
28 | geometry = 'Polygon'
|
---|
29 | else
|
---|
30 | geometry = 'Line'
|
---|
31 | end
|
---|
32 | end
|
---|
33 | end
|
---|
34 | contours(i).Geometry=geometry;
|
---|
35 | contours(i).id=i;
|
---|
36 | contours(i).X=shp(i).x;
|
---|
37 | contours(i).Y=shp(i).y;
|
---|
38 | end
|
---|
39 |
|
---|
40 | shapewrite(contours,shapefilename);
|
---|
41 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.