[36a647]: doc / octproj.tex  Maximize  Restore  History

Download this file

288 lines (231 with data), 10.4 kB

  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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
\documentclass[10pt,a4paper]{article}
\usepackage{tocbibind}
\usepackage{hyperref}
\hypersetup{colorlinks,citecolor=red,linkcolor=red,urlcolor=red}
\newcommand{\octproj}{\texttt{OctPROJ}}
\newcommand{\proj}{\texttt{PROJ.4}}
\newcommand{\octave}{GNU Octave}
\title{\octproj\\Calling \proj{} from \octave\footnote{This document is
distributed under the terms of the GNU Free Documentation License.
Please, see \url{http://www.gnu.org/licenses/}}}
\author{Jos\'e Luis Garc\'ia Pallero\footnote{ETSI en Topograf\'ia, Geodesia y
Cartograf\'ia, Universidad Polit\'ecnica de Madrid.
\texttt{jlg.pallero@upm.es}, \texttt{jgpallero@gmail.com}}}
\date{October 1, 2012 (version 1.1.1)\\
April 13, 2012 (version 1.1.0)\\
May 13, 2011 (version 1.0.2)\\
November 29, 2010 (version 1.0.1)\\
February 9, 2010 (version 1.0.0)}
\begin{document}
\maketitle
% \tableofcontents
\nocite{eat-om}
\nocite{projman}
\nocite{projir1}
\nocite{projir2}
\nocite{sny-wm}
\begin{abstract}
This is a small introduction to using the \octproj{} package. In this text, you
can overview the basic usage of the functions in
\octave\footnote{\url{http://www.octave.org}}. If you need a detailed
description about the options and available projections, please visit the
\proj{} website\footnote{\url{http://trac.osgeo.org/proj}}.
\end{abstract}
\section{Overview}
\octproj{} allows you to perform cartographic projections in \octave{} using
\proj{} library. You can take the power of \proj{} using the facilities that
\octave{} provides, without know the internals of the \proj{} C API. You can use
the conversion programs coming with \proj{} distribution, but for use them in
\octave{} you must make system calls. With \octproj{}, \proj{} can be integrated
in \octave{} scripts in a natural way.
\section{Installation}
As several \octave{} packages, \octproj{} installation consists in compiling the
C++ kernel sources (see section \ref{op-kw}), link them against \octave{}
library to generate \texttt{*.oct} functions and copy this \texttt{*.oct}
executables and other \texttt{*.m} functions into a working directory.
The automagic procedure can be easily done by running the command:
\begin{verbatim}
octave:1> pkg install octproj-x.x.x.tar.gz
\end{verbatim}
where \texttt{x.x.x} is the version number.
After that, the functions and documentation are installed in your machine and
you are ready for use the package.
\section{Kernel wrapper}
\label{op-kw}
The main functions (the functions which make the actual computations) are
programmed in a separate files: \texttt{projwrap.h} and \texttt{projwrap.c}.
The files contain three functions:
\begin{itemize}
\item \texttt{proj\_fwd}: forward computation of geodetic to projected
coordinates.
\item \texttt{proj\_inv}: inverse computation of projected to geodetic
coordinates.
\item \texttt{proj\_transform}: general transformations. Is possible to make
forward, inverse and other transformations using only one function (see
\proj{} documentation).
\end{itemize}
\subsection{Error handling}
Error handling in the kernel wrapper is based on error codes from \proj.
Functions in \texttt{projwrap} return the \proj{} error code and the \proj{}
text string error message, which can be catched in order to work in this case.
The functions can stop the execution in presence of errors depending on the
nature of the error.
\begin{itemize}
\item If exist an error involving a general parameter of the projection, the
execution stops.
\item If an error is found due to a wrong or out of domain input coordinate, the
execution don't stops, but the error code is activated and the output
transformed coordinate corresponding to the error position have a special
value.
\end{itemize}
\section{\octave{} functions}
Two types of functions are programmed for \octave: \texttt{*.oct} functions and
\texttt{*.m} functions.
\subsection{\texttt{*.oct} functions}
\label{op-of}
These functions are linked with \texttt{projwrap}. You can use it, but is no
recommended because the input arguments are more strict (always column vectors)
than \texttt{*.m} functions and don't check for errors.
The functions are:
\begin{itemize}
\item \texttt{\_op\_geod2geoc}: transformation between geodetic and cartesian
geocentric coordinates. This function calls directly \proj.
\item \texttt{\_op\_geoc2geod}: transformation between cartesian geocentric
and geodetic coordinates. This function calls directly \proj.
\item \texttt{\_op\_fwd}: forward projection (calls \texttt{proj\_fwd}).
\item \texttt{\_op\_inv}: inverse projection (calls \texttt{proj\_inv}).
\item \texttt{\_op\_transform}: general transformation (calls
\texttt{proj\_transform}).
\end{itemize}
\subsection{\texttt{*.m} functions}
These functions make the computations by calling the \texttt{*.oct} functions.
You must call these functions because you can use various types of input
(scalars, vectors or matrices) and checking of input arguments (data type,
dimensions) is performed.
The functions are the same as in section \ref{op-of} (without the \texttt{\_} at
the beginning of the name):
\begin{itemize}
\item \texttt{op\_geod2geoc}: calls \texttt{\_op\_geod2geoc}.
\item \texttt{op\_geoc2geod}: calls \texttt{\_op\_geoc2geod}.
\item \texttt{op\_fwd}: calls \texttt{\_op\_fwd}.
\item \texttt{op\_inv}: calls \texttt{\_op\_inv}.
\item \texttt{op\_transform}: calls \texttt{\_op\_transform}.
\end{itemize}
\subsection{Error handling}
\texttt{*.oct} and \texttt{*.m} functions can emit errors or warnings, some due
to errors in input arguments and other due to errors in functions from
\texttt{projwrap} kernel execution (see section \ref{op-kw}).
Errors due to wrong input arguments (data types, dimensions, etc.) can be only
given for \texttt{*.m} functions and this is the reason because the use of these
functions are recommended. In this case, the execution is aborted and nothing is
stored in output arguments.
Errors due to the execution of \texttt{projwrap} kernel can be emitted for both
\texttt{*.oct} and \texttt{*.m} functions. If the error is due to an erroneous
projection parameter, the execution is aborted and nothing is stored in output
arguments; but if the error is due to a wrong or out of domain input coordinate,
a warning is emitted and the execution has a normal end.
\section{Examples}
\subsection{Geodetic to geocentric and vice versa}
\begin{verbatim}
lon=-6*pi/180;lat=43*pi/180;h=1000;
[x,y,z]=op_geod2geoc(lon,lat,h,6378388,1/297)
x = 4647300.72326257
y = -488450.988568138
z = 4328259.36425774
[lon,lat,h]=op_geoc2geod(x,y,z,6378388,1/297);
lon*=180/pi,lat*=180/pi,h
lon = -6
lat = 43
h = 1000.00000000074
\end{verbatim}
\subsection{Forward and inverse projection}
\begin{verbatim}
lon=-6*pi/180;lat=43*pi/180;
[x,y]=op_fwd(lon,lat,'+proj=utm +lon_0=3w +ellps=GRS80')
x = 255466.980547577
y = 4765182.93268401
[lon,lat]=op_inv(x,y,'+proj=utm +lon_0=3w +ellps=GRS80');
lon*=180/pi,lat*=180/pi
lon = -6.00000000003597
lat = 42.9999999999424
\end{verbatim}
\subsection{Forward and inverse projection: \texttt{op\_transform}}
\subsubsection{With altitude}
\begin{verbatim}
lon=-6*pi/180;lat=43*pi/180;h=1000;
[x,y,h]=op_transform(lon,lat,h,'+proj=latlong +ellps=GRS80',...
'+proj=utm +lon_0=3w +ellps=GRS80')
x = 255466.980547577
y = 4765182.93268401
h = 1000
[lon,lat,h]=op_transform(x,y,h,...
'+proj=utm +lon_0=3w +ellps=GRS80',...
'+proj=latlong +ellps=GRS80');
lon*=180/pi,lat*=180/pi,h
lon = -6.00000000003597
lat = 42.9999999999424
h = 1000
\end{verbatim}
\subsubsection{Without altitude}
\begin{verbatim}
lon=-6*pi/180;lat=43*pi/180;
[x,y]=op_transform(lon,lat,'+proj=latlong +ellps=GRS80',...
'+proj=utm +lon_0=3w +ellps=GRS80')
x = 255466.980547577
y = 4765182.93268401
[lon,lat]=op_transform(x,y,'+proj=utm +lon_0=3w +ellps=GRS80',...
'+proj=latlong +ellps=GRS80');
lon*=180/pi,lat*=180/pi
lon = -6.00000000003597
lat = 42.9999999999424
\end{verbatim}
\subsection{Error due to an erroneous parameter}
\begin{verbatim}
lon=-6*pi/180;lat=43*pi/180;
[x,y]=op_fwd(lon,lat,'+proj=utm +lon_0=3w +ellps=GRS8')
error:
In function op_fwd:
In function _op_fwd:
Projection parameters
unknown elliptical parameter name
+proj=utm +lon_0=3w +ellps=GRS8
\end{verbatim}
\subsection{Error due to latitude too big}
\begin{verbatim}
lon=[-6*pi/180;-6*pi/180];lat=[43*pi/180;43];
[x,y]=op_fwd(lon,lat,'+proj=utm +lon_0=3w +ellps=GRS80')
warning: _op_fwd:
warning: Projection error in point 2 (index starts at 1)
x =
255466.980547577
Inf
y =
4765182.93268401
Inf
\end{verbatim}
\section{Notes}
Apart from \url{http://octave.sourceforge.net/octproj/index.html}, an up to date
version of \octproj{} can be downloaded from
\url{https://bitbucket.org/jgpallero/octproj/}.
\begin{thebibliography}{99}
\bibitem{eat-om} \textsc{Eaton}, John W.; \textsc{Bateman}, David, and
\textsc{Hauberg}, S\o{}ren; GNU Octave. A high-level interactive
language for numerical computations; Edition 3 for Octave
version 3.2.3; July 2007; Permanently updated at
\url{http://www.gnu.org/software/octave/docs.html}.
\bibitem{projman} \textsc{Evenden}, Gerald I.; Cartographic Projection
Procedures for the UNIX Environment---A User's Manual; USGS
Open-File Report 90-284; 2003;
\url{ftp://ftp.remotesensing.org/proj/OF90-284.pdf}.
\bibitem{projir1} \textsc{Evenden}, Gerald I.; Cartographic Projection
Procedures Release 4, Interim Report; 2003;
\url{ftp://ftp.remotesensing.org/proj/proj.4.3.pdf}.
\bibitem{projir2} \textsc{Evenden}, Gerald I.; Cartographic Projection
Procedures Release 4, Second Interim Report; 2003;
\url{ftp://ftp.remotesensing.org/proj/proj.4.3.I2.pdf}.
\bibitem{sny-wm} \textsc{Snyder}, John Parr; Map Projections: A Working Manual;
USGS series, Professional Paper 1395; Geological Survey
(U. S.), 1987;
\url{http://pubs.er.usgs.gov/usgspubs/pp/pp1395}.
\end{thebibliography}
\end{document}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks