example_my_project.html 7.69 KB
Newer Older
Geoffrey Cowles's avatar
Geoffrey Cowles committed
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of example_my_project</title>
  <meta name="keywords" content="example_my_project">
  <meta name="description" content="function [out_east,out_north] = my_project(in_east,in_north,direction)">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">fvcom_prepro</a> &gt; example_my_project.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for fvcom_prepro&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>example_my_project
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [out_east,out_north] = my_project(in_east,in_north,direction)</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>This is a script file. </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">function [out_east,out_north] = my_project(in_east,in_north,direction)</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">%function [out_east,out_north] = my_project(in_east,in_north,direction)</span>
0002 
0003 <span class="comment">% Sample user-defined projection and inverse projection of (lon,lat) to (x,y)</span>
0004 <span class="comment">% Copy to my_project (not a member of the toolbox) and modify to suite you</span>
0005 <span class="comment">%</span>
0006 <span class="comment">% function [out_east,out_north] = my_project(in_east,in_north,direction)</span>
0007 <span class="comment">%</span>
0008 <span class="comment">% DESCRIPTION:</span>
0009 <span class="comment">%    Define projections between geographical and Euclidean coordinates</span>
0010 <span class="comment">%</span>
0011 <span class="comment">% INPUT:</span>
0012 <span class="comment">%   in_east   = 1D vector containing longitude (forward) x (reverse)</span>
0013 <span class="comment">%   in_north  = 1D vector containing latitude  (forward) y (reverse)</span>
0014 <span class="comment">%   direction = ['forward' ;  'inverse']</span>
0015 <span class="comment">%</span>
0016 <span class="comment">% OUTPUT:</span>
0017 <span class="comment">%   (lon,lat) or (x,y) depending on choice of forward or reverse projection</span>
0018 <span class="comment">%</span>
0019 <span class="comment">% EXAMPLE USAGE</span>
0020 <span class="comment">%    [lon,lat] = my_project(x,y,'reverse')</span>
0021 <span class="comment">%</span>
0022 <span class="comment">% Author(s):</span>
0023 <span class="comment">%    Geoff Cowles (University of Massachusetts Dartmouth)</span>
0024 <span class="comment">%</span>
0025 <span class="comment">% Revision history</span>
0026 <span class="comment">%</span>
0027 <span class="comment">%==============================================================================</span>
0028 
0029 <span class="comment">%subname = 'my_project';</span>
0030 <span class="comment">%fprintf('\n')</span>
0031 <span class="comment">%fprintf(['begin : ' subname '\n'])</span>
0032 
0033 <span class="comment">%------------------------------------------------------------------------------</span>
0034 <span class="comment">% Parse input arguments</span>
0035 <span class="comment">%------------------------------------------------------------------------------</span>
0036 
0037 ProjectDirection = <span class="string">'forward'</span>;
0038 
0039 <span class="keyword">if</span>(direction == <span class="string">'forward'</span>)
0040     ProjectDirection = <span class="string">'forward'</span>;
0041         lon = in_east;
0042         lat = in_north;
0043 <span class="keyword">else</span>
0044     ProjectDirection = <span class="string">'inverse'</span>;
0045         x = in_east;
0046         y = in_north;
0047 <span class="keyword">end</span>;
0048 
0049 
0050 
0051 <span class="comment">%------------------------------------------------------------------------------</span>
0052 <span class="comment">% Perform the projection:  USER DEFINED</span>
0053 <span class="comment">% Example:  project/inverse project to state plane 1802</span>
0054 <span class="comment">%------------------------------------------------------------------------------</span>
0055 
0056 <span class="comment">%if(ProjectDirection == 'forward')</span>
0057 <span class="comment">%    fprintf('Projecting from (lon,lat) to (x,y)\n');</span>
0058 <span class="comment">%    [x,y] = sp_proj('1802','forward',lon,lat,'m');</span>
0059 <span class="comment">%</span>
0060 <span class="comment">%else</span>
0061 <span class="comment">%    fprintf('Inverse Projecting from (x,y) to (lon,lat)\n')</span>
0062 <span class="comment">%    [lon,lat] = sp_proj('1802','inverse',x,y,'m');</span>
0063 <span class="comment">%end;</span>
0064 
0065 <span class="comment">%------------------------------------------------------------------------------</span>
0066 <span class="comment">% Skagit, UTM, Zone 10 (see http://www.dmap.co.uk/utmworld.htm)</span>
0067 <span class="comment">%------------------------------------------------------------------------------</span>
0068 m_proj(<span class="string">'UTM'</span>,<span class="string">'longitude'</span>,[-123,-120],<span class="string">'latitude'</span>,[47,49],<span class="string">'zone'</span>,10,<span class="string">'hemisphere'</span>,<span class="string">'north'</span>,<span class="string">'ellipsoid'</span>,<span class="string">'wgs84'</span>)
0069 <span class="comment">%m_proj get</span>
0070 <span class="comment">%[x,y] = m_ll2xy(-122.530820 , 48.363114);</span>
0071 <span class="comment">%fprintf('x %f y %f\n',x,y-1e7);</span>
0072 <span class="comment">%fprintf('should be 534752, 5356766.\n')</span>
0073 deltay = 1e7;
0074 
0075 <span class="keyword">if</span>(ProjectDirection == <span class="string">'forward'</span>)
0076 <span class="comment">%    fprintf('Projecting from (lon,lat) to (x,y)\n');</span>
0077     [x,y]=m_ll2xy(lon,lat); 
0078     y = y - deltay; <span class="comment">%why?</span>
0079 <span class="keyword">else</span>
0080 <span class="comment">%    fprintf('Inverse Projecting from (x,y) to (lon,lat)\n')</span>
0081     [lon,lat]=m_xy2ll(x,y+deltay); 
0082 <span class="keyword">end</span>;
0083 
0084 
0085 <span class="comment">% set the output</span>
0086 <span class="keyword">if</span>(ProjectDirection == <span class="string">'forward'</span>)
0087   out_east = x;
0088   out_north = y;
0089 <span class="keyword">else</span>
0090   out_east = lon;
0091   out_north = lat;
0092 <span class="keyword">end</span>;
0093</pre></div>
138
<hr><address>Generated on Thu 19-Mar-2015 12:20:56 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
Geoffrey Cowles's avatar
Geoffrey Cowles committed
139 140
</body>
</html>