Environmental Engineering Reference
In-Depth Information
model region. However, when the model region is irregular, the choice may not be
appropriate any more. Another choice of coordinates refers to those from geodetic
projections. Numerous different projections are common in different countries
of the world, even within countries, and this is not the place to go into details.
The procedure which enables the user to have any real world coordinates available
on the display, showing the map, is known as geo-referencing.
There are various ways of geo-referencing. One way is to specify the coordinates
of two opposite corners. Often the positions for which exact coordinates are known
are not identical with the corners of the map. Then two positions within the image
can be chosen to which all others are related. There is one condition for the
procedure to work well, which is that the two selected points may not have the
same x - or the same y -coordinates. For this task an M-file is presented below.
For those with access to the MATLAB@ mapping toolbox , it may be more
convenient to work with the more general approach there. In the toolbox a 3
2
transformation matrix R is used, which enables the transformation for a tilted image
and for a geoid (see: http://www.mathworks.com/products/mapping/ ) .
In the following commands, which continue the command listing from the
previous subchapter, the user chooses the image positions by mouse-click and
enters the real world coordinate values in an input box.
%------------------------ Geo-reference ---------------------------
h = gca; hold on;
h0 = text (0,-ly*0.05,'Set referencepoint 1','BackgroundColor'...
,'y','EdgeColor','red','LineWidth',2);
[x0,y0,but] = ginput(1);
h1 = plot (x0,y0,'k+');
coords = inputdlg({'horizontal','vertical'},'Field
position',1,{'0','0'});
xx0 = str2double(coords(1)); yy0 = str2double(coords(2));
delete (h0);
h0 = text (0,-ly*0.05,'Set referencepoint 2','BackgroundColor',...
'y','EdgeColor','red','LineWidth',2);
[x1,y1,but] = ginput(1);
h2 = plot (x1,y1,'k+');
coords = inputdlg({'horizontal','vertical'},'Field
position',1,{'4000','3000'});
xx1 = str2double(coords(1)); yy1 = str2double(coords(2));
delete (h0,h1,h2);
mx = (xx1-xx0)/(x1-x0); xmin = xx0-mx*x0; xmax = xx1+mx*(lx-x1);
my = (yy1-yy0)/(y1-y0); ymin = yy0-my*y0; ymax = yy1+my*(ly-y1);
ax1 = axes ('Position',get(ax1,'Position'),...
'Color','none','XLim',[xmin xmax],'Ylim',[ymin ymax]);
In the second command line, the text 'Set reference point 1' is displayed below
the bottom axis of the figure. The user is informed that a location has to be set on
the image by mouse-click. ginput is the MATLAB
command that delivers the
location of the mouse during a mouse click. The third command demonstrates its
®
Search WWH ::




Custom Search