You are on page 1of 20

Document owner Approved

Version 1.0 23/02/2015 ABR BND


COO
K:\EXCHANGE\tdb\Handleidingen en huisregels\QU15057_Technical Protocol of Matlab Plotting Tool_v1.0.docx

Protocol of Matlab Plotting Tool


Table of Contents
1. INTRODUCTION: ........................................................................................................................................ 2
2. SETUP ............................................................................................................................................................ 2
3. STEP 1: CONTROL THE BATHYMETRY ASCII FILES ...................................................................... 2
4. STEP 2: DATA CONVERSION .................................................................................................................. 3
5. STEP 3: PLOTTING THE DATA ............................................................................................................... 5
6. USEFUL HINTS .......................................................................................................................................... 18
Protocol of Matlab Plotting Tool

1. INTRODUCTION:
Matlab plotting tool produces different maps from the bathymetry ASCII files. This tool is written by
Alexander Breugem and consist of two executable files. Matlab plotting tool in the first step converts
the data file of the bathymetry to the Matlab file. Then from the Matlab file different maps can be
produced. It should be mentioned that in order to work with this tool, Matlab knowledge and also a
Matlab licence is not needed. The protocol of this tool is divided in the followings 3 steps:
Step 1: Control the bathymetry ASCII files
Step 2: Data conversion
Step 3: Plotting the data
The above steps with illustrative figures are explained separately in the followings paragraphs. As an
example a series of data and the plots are also presented in the following address:
S:\in-house\programmas\Metingen\GUI\Differencemaps\Executable\Example for Protocol of Matlab
Plotting Tool.

2. SETUP
In order to run the Matlab plotting tools, the MRE (Matlab runtime environment) needs to be installed.
The MRE is a program that enables you to run compiled Matlab code. In this way, you can use
programs made in Matlab, without the need of a Matlab licence. The MRE is located in:
S:\commercial\Matlab_Software\Matlab_runtime_environment\win32_runtime_R2009\win32
Just run the file MCRInstaller.exe once, in order to install the MRE on your PC. After that, you will be
able to use the compiled programs.

3. STEP 1: CONTROL THE BATHYMETRY ASCII FILES


This file should have the extension of xyz.
Example: BL 2009-62 Plan d'ensemble 200khz 7m juillet.xyz
The file should consist of only 3 columns of x, y and z. In each row the data should be separated from
each other by a space (and not a tab).
Example: Acceptable Non acceptable
546056.43 335999.24 0.69 546056.43 335999.24 0.69
546063.77 335997.67 0.72 546063.77 335997.67 0.72
546102.01 336004.75 -0.85 546102.01 336004.75 -0.85
... ...
In some files 4 columns exist, 3 columns of x, y and z and 1 column for the date. The date column
should be eliminated manually. In order to have the date, the user can type it in the file name.
It is important to know what the positive and the negative signs mean in the z-column (height or
depth). It is good to ask the provider of the bathymetry ASCII files. If there is no way to know the
meaning of the signs, the user can continue and then guess from the plotted map.
Hint: Usually the depth is positive for marine charts and the height has positive sign for land chart.

I/QU/00099/15.057/ABR page 2
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

4. STEP 2: DATA CONVERSION


To convert the xyz-file to the mat-file, the executable file “ConvertMaps.exe” is used. This file situated
at the following address:
S:\in-
house\programmas\Metingen\GUI\Differencemaps\Executable\ConvertMaps\distrib\ConvertMaps.exe
It is recommended to copy “ConvertMaps.exe” to the folder where the user has saved the working data.
By opening the “ConvertMaps.exe” the two following windows presented in Figure 1 appear (one after
the other which take about 5 second).

Figure 1: The windows for converting the data from xyz format to Matlab format

I/QU/00099/15.057/ABR page 3
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

The user should fill in the boxes of the Convertdata-window (see figure 2).
The directory of the xyz-files should be entered in the “Input directory:”. The same directory can be
entered in the “Output directory:” (user can also use the “Browse keys”).

Figure 2: Filling the boxes of the Converdata-windows

By clicking on the “Data limits” the program find the 4 corners that contain all the point of the “Input
directory” (see Figure 2). It is better to round the corners. The values in the lower left should be
rounded down and in the upper right should be rounded up. This option also gives the ability of
zooming on a certain area.
The four corners can be rounded as follows:
545413.57 to 545000 335800.78 to 335500
548078.61 to 548500 339438.31 to 339500
So the area would be 3500 m × 4000 m. A mesh is generated for the entire area. The mesh consists of
the elements with the shape of rectangle Delta X × Delta Y (by the two boxes of “Delta” the area is
divided in to the rectangular elements). If 5 m be considered for both delta, the number of elements

I/QU/00099/15.057/ABR page 4
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

would be 700 × 800. This amount of elements is seems to give an acceptable results. However, by
increasing the elements (by decreasing the two deltas) the precision but also the calculation time
increases. It should be noticed that the number of elements of 2000 × 2000 is too much for this
executable file.

Optional settings are designed to filter out the anomalies. Three boxes in this part can be filled in.

- Minimum depth (shallower depths are eliminated): This will give the ability of removing the data
from sea level to a special depth. This option can only be used for the maritime chart
convention.

- Maximum distance to measurements (larger is eliminated): For all the rectangular elements a
data point in the centre of the element is produced (interpolated). Interpolated points further
than “maximum distance to measurements” from the closest measuring points will be
eliminated. If the two adjacent lines of the data points are 100 m far from each other, then
“maximum distance to measurements” can be considered as 55 m (or 60 m: more than half of
the distance). It is recommended to run the file without any filtering. Then by looking at the
produced maps, user can have the idea of limiting the interpolation in order to filter out the
anomalies (later, it is illustrated).

- Maximum length triangulation (larger is eliminated): A triangulation is made among each three
data points. If the distance between the two adjacent lines of the data points are 100 m, the
maximum length of the triangles is a bit more than 100 m (i.e. 105 or 110 m). So, by choosing
120 m (as an example) for this box, all the interpolated points in triangles with a maximum
length of the sides longer than 120 m, will be eliminated. The user should be aware of
enormous increase of the calculation time. Therefore, it is recommended to use “maximum
distance to measurements” rather than “maximum length triangulation".

By clicking on the “Convert files” key, Matlab files of the converted data are produced in a directory
“mat_files” (this directory is produced by the tool).

5. STEP 3: PLOTTING THE DATA


To plot the different maps from the data of the xyz-file, the executable file “PlotMaps.exe” is used. This
file is situated in the following address:
S:\in-house\programmas\Metingen\GUI\Differencemaps\Executable\PlotMaps\distrib\PlotMaps.exe
It is recommended to copy “PlotMaps.exe” to the folder that user has the working data.
By opening the “PlotMaps.exe” the two following windows presented in Figure 3 appear (one after the
other which take about 5 second).

I/QU/00099/15.057/ABR page 5
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

The user should fill in the boxes of the Plotdata-window.


The directory of the mat_files should be entered in the “Input directory:”. The same directory as used
for step 2 (Convertdata) can be entered in the “Output directory:” (user can also use the “Browse
keys”).
This tool has the ability of showing specific area (e.g. the different dredging zones) by introducing some
polygons. It is recommended to define some polygons in the measurement area. This helps the user to
limit the (wrong) interpolations and to filter out anomalies. For this purpose two text-files should be
prepared. The file name should be exactly as follows:

- anyname. txt: this file (e.g. Polygons.txt) contains the coordinates of all the required polygons,
separately (see Figure 4, left)
- anynameText.txt : by this file (e.g. PolygonsText.txt) user can name each polygon (see Figure 4,
right). The coordinates of the polygon name can be roughly the centre of the polygon.
Both files of “anyname.txt” and “anynameText.txt” should be located in the same directory. The
address of the “anyname.txt” should be entered in box of “Contours file”. The tool itself, finds the
“anynameText.txt” in the same directory.

I/QU/00099/15.057/ABR page 6
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Figure 3: The windows for plotting the data

I/QU/00099/15.057/ABR page 7
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Left: Polygons.txt
Right : PolygonsText.txt

Figure 4: An example of the text files needed for introducing the polygons surrounding the measured
area. Left: a sample for Polygons.txt that presents the polygons. Right: a sample for PolygonsText.txt
that names the polygons (roughly in the middle of each polygon)

The table in the bottom of the Plotdata-window should be filled in, with the names of the xyz.files that
user needs their plots (attention, the xyz.files and not the converted Matlab files). This table is
designed to produce the difference chart between two bathymetries (oldest and newest) and the tool
works (only) when all the columns are filled. Therefore, if user needs only the bathymetries of several
files, the “First file and date” columns should be prepared and the “Last file and date” columns can be
just a copy of the “First two columns”. However, for difference charts, mentioned columns are different.
It is recommended to prepare an excel chart with the desired columns and then paste it in the table of
the Plotdata-window (using the right mouse button).

If the number of data files are too much and putting them in an excel sheet takes a lot of time, the user
can use a specific macro to compose a list of all the files in a specified directory. This macro can be
found in the file “Make_filelist_per_directory.xlsm”1 under:
S:\in-house\programmas\Metingen\GUI\Differencemaps\Executable\ Make_filelist_per_directory.xlsm

1
macro written by Kathleen De Wit

I/QU/00099/15.057/ABR page 8
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

It is recommended to copy “Make_filelist_per_directory.xlsm” to the folder where the working data has
been saved. By opening the file, a key of “Draw up filelist” appears (see Figure 5). By clicking the key
“Draw up filelist”, the user can choose the directory of which he would like to have a file list inventory.

Figure 5: View of the excel macro file that produces the list of the file names in a specified directory

I/QU/00099/15.057/ABR page 9
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Figure 6: Filling the boxes of the Plotdata-windows

After completing the table at the bottom of the Plotdata-window, the desired plot can be chosen. Figure
6 presents the filled out form (empty in Figure3).

As presented in Figure 6, the user should select the chart convention (marine or land chart):

- If the convention is “Marine chart”, in the window of “Chart datum text” that will appear as text
at the top of the depth scale of the map, it is recommended to type “m CD (depth is +)”, which
means: meter Chart Datum, depth is considered positive (most common for marine charts).
- If the convention is “Land chart”, in the window of “Chart datum text” that will appear as text at
the top of the height scale of the map, it is recommended to type “m CD (height is +)”, which
means: meter Chart Datum, height is considered positive (most common for land charts).

Any other information, considered useful to add on the plot, can be entered in the box “Remarks added
to plot” (see Figure3). After the selection of the type of the map (see later), the user should click on the
key “Guess depth”. Then, the minimum and the maximum depth (in meter) are found and presented as

I/QU/00099/15.057/ABR page 10
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

show in Figure 6. These depths can be rounded. The presented data in Figure 6 can be rounded to -5
m and 12 m. Now, by selection of the map type everything is ready to click the “Plot data” key in order
to have the maps in the specified directory.

User can select the desired map between the 6 available maps as presented in Figure 6. The following
options are available:

- “Data points”: plots all the data points (see Figure 7) and puts these plots in a directory called
“transects”. In the mentioned directory a file called “TableBath.csv” gives a summary of the
depth information within all the polygons. TableBath.csv can be saved as an excel file. Per
polygon is summarised: the average depth with its standard deviation and the minimum and
maximum depth (see Figure 8).
Attention: CSV use comma as list separator and dot as decimal symbol. These can be
changed in:
- Control panel
- Region and language
- Formats (tab)
- Additional settings

I/QU/00099/15.057/ABR page 11
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Figure 7: Example of a plot of the data points

Figure 8: Example of the file presenting a summary of the depth information per polygon (average
depth with standard deviation, minimum and maximum depth)

- “Maps”: plots the bathymetry (see Figure 9) and puts these plots in a directory called
“bathymetry”. In the mentioned directory, a file called “TableBath.csv” summarises the depth
information per polygon.

I/QU/00099/15.057/ABR page 12
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Figure 9: Example of a plot of the bathymetry


- “Differences”: the results of this part is based on the difference between the oldest and the
newest data files. The way of calculation is explained (whether oldest - newest or newest -
oldest) by the following examples :
Most common for marine charts:
values above chart datum (CD) : negative
values below chart datum (CD) : positive
The difference chart in marine convention is calculated as Date 1 – Date 2 or in other words
oldest - newest2. In this case sedimentation is positive and erosion is negative (see Figure
10).

D4 -4
D3 -2
0 m CD Sedimentation: Erosion:
D2 +2
D1 - D2 > 0 D1 - D2 < 0
D1 +4

Z D3 – D4 > 0 D3 – D4 < 0

2
Date 1 < Date 2 < Date 3 < Date 4 are ordered chronologically.

I/QU/00099/15.057/ABR page 13
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Figure 10: Verification example for difference chart in marine convention, CD stands for chart datum
and D for the date of bathymetry

Most common for land charts:


values above chart datum (CD) : positive
values below chart datum (CD) : negative
The difference chart in marine convention is calculated as Date 2 – Date 1 or in other words
newest - oldest . By choosing this option, again sedimentation is positive and erosion is
negative (see Figure 11).

Z (m)

D2 +3
+2
D1 +1
0 m CD
Sedimentation: Erosion:
D4 -1
-2 D2 – D1 > 0 D2 – D1 < 0
D3 -3
D4 – D3 > 0 D4 – D3 < 0
Figure 11: Verification example for difference chart in land convention, CD stands for chart datum and
D for the date of bathymetry
The following colour scale is chosen to present the processes of sedimentation and erosion (see Figure
12):
difference = positive value → fill → sedimentation ; presented in red
difference = negative value → cut → erosion ; presented in blue

Z (m)

Sedimentation +2
+1
0
-1
Erosion -2

I/QU/00099/15.057/ABR page 14
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Figure 12: Colour scale used in differential charts

It should be noted that in this part “guess depth” gives the minimal and maximal difference in
depth between the 2 bathymetries. Based on the above explanation the “Differences” plots the
difference map between the two files located in each row of the table of the Plotdata-window
(see Figure 13) and put the plots in a directory called “diff”. A file (Table.csv) is also produced
(see Figure 14) and put in the “diff” directory for the difference calculations. The file Table.csv,
can be saved as an excel file. The mentioned file has 8 columns and the results of the
differentials are presented for each row of the filled table in Plotdata-window. The results are
presented per polygon. For the first difference and the first polygon presented in Figure 14, the
following columns are shown (numbers are rounded):
1- First file : The name of the oldest file (BL 2007-33 …)
2- Second file: The name of the newest file (BL 2008-35 …)
3- Volume Diff (Polygon 1) ) [m^3]: Sum of cut and fill volumes: 23244 + (-5647) = 17597 m³
4- Volume Diff Cut (Polygon 1) ) [m^3]: Cut volumes (always negative): -5647 m³
5- Volume Diff Fill (Polygon 1) [m^3]: Fill volumes (always positive): 23244 m³
6- Used Area (Polygon 1) [m^2]: The part of polygon 1 that is covered by data points: 239175
m² which in this example is 99.2% (239175/241092) of the complete surface of polygon 1.
In the case that the coverage percentage is too low (e.g. 25%), user should be aware of
the interpretations, as the result is not representative for the entire area.
7- Area complete polygon 1 [m^2]: Complete area (surface) of polygon1: 241092 m²
(calculated using surveyors equation)
8- Avg Difference (Polygon 1) [m]: This thickness corresponds to the difference volume (col
3) divided over the used area: 17597m³ / 239175m² = 0.07 m = 7 cm

I/QU/00099/15.057/ABR page 15
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Figure 13: Example of a plot of the differential chart

Figure 14: Example of an excel file produced for the difference chart

- “Data points +Maps”: plots the data points on the bathymetry (see Figure 15) and puts these
plots in a directory called “bathtrans”. Also in this directory the file TableBath.csv, (as before
introduced) presents a summary of the depth information per polygon.

I/QU/00099/15.057/ABR page 16
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

- “Data points (old) + Differences”: plots the data points of the oldest file on the difference map
and puts these plots in a directory called “difftransold”. The file Table.csv, introduced in
“Differences” is also presented in this directory.

- “Data points (new) + Differences”: plots the data points of the newest file on the difference map
and puts these plots in a directory called “difftransnew”. The file Table.csv, introduced in
“Differences” is also presented in this directory.

Figure 15: Example of a plot of the data points on the bathymetry

I/QU/00099/15.057/ABR page 17
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

6. USEFUL HINTS
This paragraph gives several hints to produce the desired maps with the least trial and error. The
following systematic approach is proposed:

1- Open both windows of “Convertdata” and “Plotdata”.


2- Complete all the boxes in “Convertdata” except for “optional settings” and click the “Convert files”
key.
3- Complete all the boxes in “Plotdata” by selecting “Data points+Maps”. Having a look at the
bathymetry with the data points on the map, gives a good idea whether or not the interpolation
between the points is done correctly.
4- After clicking the “Guess depth” and the “Plot data”, the user should examine the maps in the
“bathtrans” directory. As an example, Figure 16 shows a sample of the produced map. As can be
seen in this figure, the depth interpolation is also done for the area (marked with white stars), where
there are no data points. It shows that “Maximum distance to measurements (larger is eliminated)”
key in “Optional settings” should be used in order to filter out these anomalies. In the mentioned
example, the maximum distance between the data point tracks is about 100 m. So in the first
estimation, any data further than 50 m from the measurements should be eliminated.
5- In a second try, the converted data and the produced maps will be overwritten in their specified
directory. The directory of the previous “mat_files” should therefore be changed if the user wants to
keep both Matlab files. This is also the case for the maps of bathymetries with the data points in the
“bathtrans” directory.
6- Put 50 in the “Maximum distance to measurements (larger is eliminated)” key in “Optional settings”
of “Convertdata” and click the “Convert files” key.
7- Clicking the “Plot data” in “Plotdata” window, allows the user to see the new maps in the “bathtrans”
directory. Figure 17 shows the reproduced map of Figure 16 by using the filtering setting. As can be
seen in this figure, there is no longer a wrong depth interpolation for the area with no data points.
However, some white points can be observed in the upper polygon. White points indicate that there
is no data. Therefore, the user should decrease the domain of the eliminated points. Therefore,
“Maximum distance to measurements (larger is eliminated)” key in “Optional settings” should be
increased to (e.g.) 60 m.
8- By choosing 60 m instead of 50 m in step 6, and clicking the “Plot data” in “Plotdata” window, the
new map is produced in “bathtrans” directory. Figure 18 shows the new reproduced map of Figure
16. As can be seen in this figure, the wrong depth interpolation for the area with no data points and
also the white points between the data points are now gone.

I/QU/00099/15.057/ABR page 18
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Figure 16: Example of a plot of the data points on the bathymetry with no filtering. White stars indicate
the areas where data points are missing, but still a depth interpolation is done.

Figure 17: Example of sample plot presented in Figure 16 with 50 m filtering. White areas indicate a
lack of data.

I/QU/00099/15.057/ABR page 19
versie 1.0 - 23/02/2015
Protocol of Matlab Plotting Tool

Figure 18: Example of sample plot presented in Figure 16 with 60 m filtering

9- The “guess depth key” should be clicked for the differential charts. If the minimal and the maximal
depth difference values differ largely, (e.g. between -4 and +8 m), the user will observe only one
colour roughly over the entire area of the differential chart. This means that the two extremes (e.g. -
4 and 8 m) correspond to a tiny limited area or some boundaries which are not strait forward visible.
In this case the upper and lower limits should be chosen closer together by entering other values
manually. A minimal depth difference value set to -2 m and a maximal depth difference value set to
+2 m, usually gives a good result in case of maintenance dredging projects, where sedimentation
between dredging campaigns or realised dredging depth hardly ever exceed these values.

I/QU/00099/15.057/ABR page 20
versie 1.0 - 23/02/2015

You might also like