You are on page 1of 144

Mapping

Mapping
Introduction to MATLAB mapping Toolbox
Map projection
MATLAB mapping Toolbox and georeferencing

Laboratory exercises:

Romà Tauler (IDAEA, CSIC, Barcelona)


Maps

The simplest (although perhaps not the most general) definition of a map is a
representation of geographic data.

Map data is any variable or set of variables representing a set of geographic


locations, properties of a region, or features on a planet’s surface, regardless
of how large or complex the data is, or how it is formatted.

Geospatial data are spatial data (data where things are within a given
coordinate system) that are absolutely or relatively positioned on a planet, or
georeferenced (it has a terrestrial coordinate system that can be shared by
other geospatial data)

Geodata is coded for computer storage and applications in two principal ways:
vector and raster representations. It has been said that “raster is faster but
vector is corrector
Map examples

90° N

45° N


180° W 135° W 90° W 45° W 0° 45° E 90° E 135° E 180° E

45° S

90° S

Example 1
---------
% World map with coarse coastlines
worldmap('World') World
load coast
plotm(lat, long)
Map examples

75 °
N

60 °
N

45 °
N

30 °
N
° E
45
15 °
worldmap('Europe') W °
30 E
0° °
15 E
load coast
plotm(lat, long)
Europe
Map examples

45.0 ° N

42.5 ° N

40.0 ° N

37.5 ° N

35.0 ° N
15.0 ° W1 ° °
° 0.0 E
2.5 W10.0° W 7. ° ° E 5.0° E 7 .5 E 1
5 W 5.0 ° W 2.5° W 0.0 ° 2.5

worldmap('Spain')
load coast
plotm(lat, long)
Spain
Example 2
---------
% Worldmap with land areas, major lakes and rivers, and cities and
% populated places
ax = worldmap('World');
setm(ax, 'Origin', [0 180 0])
land = shaperead('landareas', 'UseGeoCoords', true);
geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5])
lakes = shaperead('worldlakes', 'UseGeoCoords', true);
geoshow(lakes, 'FaceColor', 'blue')
rivers = shaperead('worldrivers', 'UseGeoCoords', true);
geoshow(rivers, 'Color', 'blue')
cities = shaperead('worldcities', 'UseGeoCoords', true);
geoshow(cities, 'Marker', '.', 'Color', 'red')

90° N

45° N


0° 45° E 90° E 135° E 180° E 135° W 90° W 45° W 0°

45° S

90° S
Example 3
---------
% Map of Antarctica
worldmap('antarctica')
antarctica = shaperead('landareas', 'UseGeoCoords', true,...
'Selector',{@(name) strcmp(name,'Antarctica'), 'Name'});
patchm(antarctica.Lat, antarctica.Lon, [0.5 1 0.5])

70° S

80° S

90 °
S
Example 4
---------
% Map of Africa and India with major cities and populated places
worldmap({'Africa','India'})
land = shaperead('landareas.shp', 'UseGeoCoords', true);
geoshow(land, 'FaceColor', [0.15 0.5 0.15])
cities = shaperead('worldcities', 'UseGeoCoords', true);
geoshow(cities, 'Marker', '.', 'Color', 'blue')

30° N

0° 0° 30° E 60° E 90° E

30° S
Example 5 ---------
% Map of the geoid over South America and the central Pacific
worldmap([-50 50],[160 -30])
load geoid
geoshow(geoid, geoidrefvec, 'DisplayType', 'texturemap');
load coast
geoshow(lat, long)

The geoid approximates mean sea level. The shape of the ellipsoid was calculated
based on the hypothetical equipotential gravitational surface. A significant
difference exists between this mathematical model and the real object. However,
even the most mathematically sophisticated geoid can only approximate the real
shape of the earth.
geoid, model of the
figure of the Earth—i.e.,
of the planet’s size and
shape—that coincides
with mean sea level over
the oceans and continues
in continental areas as an
imaginary sea-level
surface defined by spirit
level. It serves as a
reference surface from
which topographic
heights and ocean depths
are measured. The
scientific discipline
concerned with the
precise figure of the Earth
and its determination and
significance is known as
geodesy.
Example 6
---------
% Map of terrain elevations in Korea
load korea
not display the
h = worldmap(map, refvec); outside of the
set(h, 'Visible', 'off') projection
geoshow(h, map, refvec, 'DisplayType', 'texturemap')
colormap(demcmap(map))

DEMCMAP Colormaps appropriate to


terrain elevation data
DEMCMAP(map) creates and
assigns a colormap appropriate for
elevation data.
The colormap has the number of land
and sea colors in proportion to the
maximum elevations and depths in
the matrix map. With no output
arguments, the colormap is applied to
the current figure and the axes
CLim property is set so that the
interface between the land and sea
is correct.
Example 7
---------
% Map of the United States of America
ax = worldmap('USA');
load coast
geoshow(ax, lat, long,...
'DisplayType', 'polygon', 'FaceColor', [.45 .60 .30])
states = shaperead('usastatelo', 'UseGeoCoords', true);
faceColors = makesymbolspec('Polygon',...
{'INDEX', [1 numel(states)], 'FaceColor', polcmap(numel(states))});
geoshow(ax, states, 'DisplayType', 'polygon', 'SymbolSpec', faceColors)
GEOSHOW Display map latitude and longitude data

GEOSHOW(LAT, LON) or
GEOSHOW(LAT, LON, ..., 'DisplayType', DISPLAYTYPE, ...)
GEOSHOW(LAT,LON,Z, ..., 'DisplayType', DISPLAYTYPE, ...)
GEOSHOW(Z,R, ..., 'DisplayType', DISPLAYTYPE,...)
GEOSHOW(LAT,LON,I)
GEOSHOW(LAT,LON,BW)
GEOSHOW(LAT,LON,X,CMAP)
GEOSHOW(LAT,LON,RGB)
GEOSHOW(..., 'DisplayType', DISPLAYTYPE, ...)
GEOSHOW(I,R)
GEOSHOW(BW,R)
GEOSHOW(RGB,R)
GEOSHOW(A,CMAP,R)
GEOSHOW(..., 'DisplayType', DISPLAYTYPE, ...)
GEOSHOW(S) or GEOSHOW(S, ..., 'SymbolSpec', SYMSPEC, ...)
GEOSHOW(FILENAME)
........

Look at HELP GEOSHOW, a very powerful MATLAB command


Example 1
---------
% Display world land areas using a default Plate Carree
projection.
figure
geoshow('landareas.shp', 'FaceColor', [0.5 1.0 0.5]);
Example 2
---------
% Create a worldmap of North America, and
% override default polygon properties.
figure
worldmap('na');
% Read the USA high resolution data.
states = shaperead('usastatehi', 'UseGeoCoords', true);
% Create a SymbolSpec to display Alaska and Hawaii as red polygons.
symbols = makesymbolspec('Polygon', ...
{'Name', 'Alaska', 'FaceColor', 'red'}, ...
{'Name', 'Hawaii', 'FaceColor', 'red'});
% Display all the other states in blue.
geoshow(states, 'SymbolSpec', symbols, ...
'DefaultFaceColor', 'blue', ...
'DefaultEdgeColor', 'black');
Example 3
---------
% Create a worldmap of the Korean data grid
% and display as a texture map.
load korea
figure
worldmap(map, refvec)
% Display the Korean data grid as a texture map.
geoshow(gca,map,refvec,'DisplayType','texturemap');
colormap(demcmap(map))
% Display the land area boundary as black lines.
S = shaperead('landareas','UseGeoCoords',true);
geoshow([S.Lat], [S.Lon], 'Color' ,'black');
Example 4
---------
% Display the EGM96 geoid heights as a texture map
% using the Eckert projection.
load geoid
% Create a figure with an Eckert projection.
figure
axesm eckert4;
framem; gridm;
axis off
% Display the geoid as a texture map.
geoshow(geoid, geoidrefvec, 'DisplayType', 'texturemap');
% Create a colorbar and title.
hcb = colorbar('horiz');

set(get(hcb,'Xlabel'),'String','EGM96 Geoid Heights in Meters.')


% Mask out all the land.
geoshow('landareas.shp', 'FaceColor', 'black');
Example 6
---------
% Display the moon albedo image using a default Plate Carree projection
% and an orthographic projection.
load moonalb
% Plate Carree projection.
figure
geoshow(moonalb,moonalbrefvec)
% Orthographic projection.
figure
axesm ortho
geoshow(moonalb, moonalbrefvec, 'DisplayType', 'texturemap')
colormap(gray(256))
axis off
% Example 7 Read and display the San Francisco South 24K DEM data.
filenames = gunzip('sanfranciscos.dem.gz', tempdir);
demFilename = filenames{1};
% Read every point of the 1:24,000 DEM file.
[lat, lon,Z] = usgs24kdem(demFilename,2);
% Delete the temporary gunzipped file.
delete(demFilename);
% Move all points at sea level to -1 to color them blue.
Z(Z==0) = -1;
% Compute the latitude and longitude limits for the DEM.
latlim = [min(lat(:)) max(lat(:))];
lonlim = [min(lon(:)) max(lon(:))];
% Display the DEM values as a texture map.
figure
usamap(latlim, lonlim)
geoshow(lat, lon, Z, 'DisplayType','texturemap')
demcmap(Z)
daspectm('m',1)
% Overlay black contour lines onto the texturemap.
geoshow(lat, lon, Z, 'DisplayType', 'contour', 'LineColor', 'black');
% View the DEM values in 3-D.
figure
usamap(latlim, lonlim)
geoshow(lat, lon, Z, 'DisplayType', 'surface')
demcmap(Z)
daspectm('m',1)
view(3)
Other Examples
Try: worldmap command (mapping Toolbox) and
select region...
>> worldmap ---> Spain or worldmap('Spain')
>> load coast
>> plotm(lat,long)
Geographic coordinates

Map coordinate systems - geographic and geomagnetic.

Latitude/Longitude is the usual coordinate system for maps.

In some cases UTM coords are also used, but these are really just a simple
transformation based on the location of the equator and certain lines of longitude.

On the other hand, there are occasions when a coordinate system based on some
other set of axes is useful. For example, in space physics data is often projected in
coordinates based on the magnetic poles

Notice that longitudes are specified using a signed notation

East longitudes are positive, whereas West longitudes are negative !!!!
Nord latitudes are positive, whereas Sud latitudes are negative!!!

Also note that a decimal degree notation is used, so that a longitude of 120 30'W is
specified as -120.5. .
MATLAB mapping toolbox

Plotting vector geodata

>>clear
>> load coast
>> axesm mercator
>> framem
>> plotm(lat,long)
whos
lat 9589x1 76712 double
long 9589x1 76712 double

plotm(lat(1:20),long(1:20),'r')
Plotting raster (grid) data in MATLAB
>> load topo
>> whos
Name Size Bytes Class Attributes

topo 180x360 518400 double


topolegend 1x3 24 double
topomap1 64x3 1536 double
topomap2 128x3 3072 double
>> axesm sinusoid
>> geoshow(topo,topolegend,'DisplayType','texturemap')
>> demcmap(topo)
>> topolegend
>> topolegend
topolegend =
1 90 0

geoshow shows geodata in


geographic unprojected
ccordinates
demcmap creates and
assigns a colormap
appropriate for elevation data.
Combining vector and raster data in the same plot
>> clma
>> clear
>> load coast
>> load topo
>> axesm robinson
>> geoshow(topo,topolegend,'Displaytype','texturemap')
>> demcmap(topo)
>> geoshow(lat,long,'Color','r')
From vectors to raster (grids)

>> indiana=shaperead('usastatehi.shp','UseGeoCoords',true,'Selector',...
{@(name)strcmpi('Indiana',name),'Name'});
>> inLat=indiana.Lat;
>> inLon=indiana.Lon;
>> gridDensity=40; Convert vector
>> [inGrid,inRefVec]=vec2mtx(inLat,inLon,gridDensity); information to
>> whos a raster grid image
Name Size Bytes Class Attributes

gridDensity 1x1 8 double


inGrid 164x137 179744 double
inLat 1x626 5008 double
inLon 1x626 5008 double
inRefVec 1x3 24 double
indiana 1x1 10960 struct
From vectors to rastrer (grids)
>> figure
>> axesm eqdcyl
>> meshm(inGrid,inRefVec)
>> colormap jet(4)
From vectors to rastrer (grids)
>> [latlim,lonlim]=limitm(inGrid,inRefVec)
latlim =
37.7107 41.8107
lonlim =
-88.1479 -84.7229
>> setm(gca,'Flatlimit',latlim,'Flonlimit',lonlim)
>> tightmap
Mapping

Mapping
Introduction to MATLAB mapping Toolbox
Map projections
MATLAB mapping Toolbox and georeferencing

Laboratory exercises:

Romà Tauler (IDAEA, CSIC, Barcelona)


Map Projections

All geospatial data must be flattened onto a display surface in order to


visually portray what exists where. The mathematics and craft of map
projection are central to this process. Although there is no limit to the ways
geodata can be projected, conventions, constraints, standards, and
applications generally prescribe its usage.
To represent a curved surface such as the Earth in two dimensions, you
must geometrically transform (literally, and in the mathematical sense,
“map”) that surface to a plane. Such a transformation is called a map
projection.
map projection consists of constructing points on geometric objects such
as cylinders, cones, and circles that correspond to homologous points on
the surface of the planet being mapped according to certain rules and
formulas.
Map Projections

But what projection should I use?

This depends really on how large an area you are mapping.

Usually, maps of the whole world are Mercator, although often the Miller Cylindrical
projection looks better because it doesn't emphasize the polar areas as much.

Another choice is the Hammer-Aitoff or Mollweide (which has meridians curving


together near the poles). Both are equal-area. It's probably not a good idea to use
these projections for maps that don't have the equator somewhere near the middle.

The Robinson projection is not equal-area or conformal, but was the choice of
National Geographic (for a while, anyway), and also appears in the IPCC reports.

If you are plotting something with a large north/south extent, but not very wide (say,
North and South America, or the North and South Atlantic), then the Sinusoidal or
Mollweide projections will look pretty good.

Another choice is the Transverse Mercator, although that is usually used only for
very large-scale maps.
Map Projections
MATLAB mapping toolbox
Projection Name Map Projection ID
--------------- -----------------
Transverse Mercator tranmerc
Mercator mercator
Lambert Conformal Conic (2SP) lambert
Lambert Conformal Conic (1SP) lambert
Lambert Azimuthal Equal Area eqaazim
Albers Equal-Area Conic eqaconic
Azimuthal Equidistant eqdazim
Equidistant Conic eqdconic
Polar Stereographic ups
Oblique Stereographic stereo
Equirectangular eqdcylin
Cassini-Soldner cassini
Gnomonic gnomonic
Miller Cylindrical miller
Orthographic ortho
Polyconic polycon
Robinson robinson
Sinusoidal sinusoid
Van der Grinten vgrint1
Map Projections
But what projection should I use?

For smaller areas within one hemisphere or other (say, Australia, the United
States, the Mediterranean, the North Atlantic) you might pick a conic projection.
The differences between the two available conic projections are subtle, and if
you don't know much about projections it probably won't make much difference
which one you use.

If you get smaller than that, it doesn't matter a whole lot which projection you
use. One projection useful in many cases is the Oblique Mercator, since you can
align it along a long (but narrow) coastal area.

If map limits along lines of longitude/latitude are OK, use a Transverse Mercator
or Conic Projection. The UTM projection is also useful.

Polar areas are traditionally mapped using a Stereographic projection, since for
some reason it looks nice to have a "bullseye" pattern of latitude lines.
If you want to get a quick idea of what any projection looks like, default
parameters for all functions are set for a "typical" usage, i.e. to get a quick idea
of what any projection looks like, you can do so without having to figure out a lot
of numerical values:
How to specify map projections in MATLAB
mapping Toolbox?

axesm Define map axes and set map properties


displaym Display geographic data from display structure
geoshow Display map latitude and longitude data
grid2image Display regular data grid as image
mapview Interactive map viewer
usamap Construct map axes for United States of America
worldmap Construct map axes for given region of world
MAPPING GUIs

AXESM GUI
AXESM activates a GUI to define a map projection for the current axes.
AXESM(PROPERTYNAME, PROPERTYVALUE,...)
AXESM(MSTRUCT,...)
AXESM(PROJFCN,...)

MAPVIEW Interactive map viewer


Use the Map Viewer to work with vector, image, and raster data grids in a map
coordinate system: load data, pan and zoom on the map, control the map scale of
your screen display, control the order, visibility, and symbolization of map layers,
annotate your map, and click to learn more about individual vector features.

MAPVIEW complements MAPSHOW and GEOSHOW, which are for constructing


maps in ordinary figure windows in a less interactive, script-oriented way.

MAPVIEW (with no arguments) starts a new Map Viewer in an empty state.

MAPSHOW Display map data without projection

MAKESYMBOLSPEC Construct vector symbolization specification


HELP for Mapping MATLAB Toolbox
• help map for computational functions
• mapdemos for a list of Mapping Toolbox demos
• maps lists all Mapping Toolbox map projections by class, name, and ID string.
• maplist returns a structure describing all Mapping Toolbox map
projections.
• projlist to list map projections supported by projfwd and projinv
• help functionname for help on a specific function, often including examples
• helpwin functioname to see the output of help displayed in the Help
browser window instead of the Command Window
• doc functionname to read a function’s reference page in the Help browser,
including examples and illustrations
MAPPING DEMOS

• mapexkmlexport — Exporting Vector Point Data to KML


• mapexfindcity — Interactive Global City Finder
• mapexgeo — Creating Maps Using geoshow (for latitude, longitude data)
• mapexmap — Creating Maps Using mapshow (for x, y data)
• mapexrefmat — Creating and Using Referencing Matrices
• mapexreg — Georeferencing an Image to an Orthotile Base Layer
• mapex3ddome — Plotting a 3-D Dome as a Mesh Over a Globe
• mapexunprojectdem — Un-Projecting a Digital Elevation Model (DEM)
• mapexgshhs — Converting Coastline Data (GSHHS) to Shapefile Format
MATLAB Functions that Access Internet Data Directly

The MATLAB functions in the table below read files from URLs. Then you can write
the files to a local directory or load them into your MATLAB Workspace. With the
exception of urlread and urlwrite, all the functions can read files on local and
network file systems using path syntax as well.
geotiffread Read a georeferenced image from GeoTIFF file
gunzip Uncompress files in the GNU-Zip format
imread Read image from graphics file
untar Extract the contents of a Tar-file
unzip Extract the contents of a Zip-file
urlread Returns the contents of a URL as a string
urlwriteSave the contents of a URL to a file
Mapping

Mapping
Introduction to MATLAB mapping Toolbox
Data Models
Map projections
MATLAB mapping Toolbox and georeferencing

Laboratory exercises:

Romà Tauler (IDAEA, CSIC, Barcelona)


Georeferencing

Raster geodata consists of georeferenced data grids and images that in MATLAB
are stored as matrices. Raster geodata looks like any other matrix in MATLAB

Georeferencing can be done to the earth globe or to a specified map projection,


so that each pixel of data occupies a known patch of territory of the planet.
Whether a raster geodata set covers the entire planet or not, its placement
and resolution must be specified.

Referencing vectors
In many instances (when the data grid or image is based on latitude and
longitude and is aligned with the geographic graticule), a referencing matrix has
more degrees of freedom than the data requires. In such cases, you can use a
more compact representation, a three-element referencing vector.
A referencing vector defines the pixel size and northwest origin for a regular,
rectangular data grid:

refvec= [cells-per-degree, north lat, west long]


refvec= [cells-per-degree, north lat, west long]

In MAT-files, this variable is often called refvec or maplegend. The first


element, cells-per-degree, describes the angular extent of each grid cell
(e.g., if each cell covers five degrees of latitude and longitude, cells-per-
degree would be specified as 0.2).

Note that if the latitude extent of cells differs from their longitude extent you
cannot use a referencing vector, and instead must specify a referencing
matrix.

The second element, north-lat, specifies the northern limit of the data grid
(as a latitude), and the third element, west-lon, specifies the western extent
of the data grid (as a longitude). In other words, north-lat, west-lon is the
northwest corner of the data grid.

Note, however, that cell (1,1) is always in the southwest corner of the
grid. This need not be the case for grids or images described by referencing
matrices, as opposed to referencing vectors.
Regular data grids

Dsta matrices that contain double values.

southermost edge is the first row


northermost edge is the last row
westernmost edge is the first column
eastermnost edge is the last column

cell(1,1) is southwest corner of the grid

East longitudes are positive, whereas West longitudes


are negative !!!!

Nord latitudes are positive, whereas Sud latitudes are


negative!!!
Building a global data grid
Build a coarse world map where each cell represents 60o

1) Built a data minigrid:


minigrid=[1,2,3,4,5,6;7,8,9,10,11,12;13,14,15,16,17,18]

2) Make a referencing vector refvec= [cells-per-degree, north


lat, west long]
minivec=[1/60,90,-180]
Building and georeferencing a global data grid

minigrid=[1,2,3,4,5,6;7,8,9,10,11,12;13,14,15,16,17,18]

minivec=[1/60,90,-180]

minigrid = -90,180 SE
-90,-180 SW
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
90,-180 NW
90,180 NE

Remember!

East longitudes are positive.


West longitudes are negative.
North latitudes are positive.
South latitudes are negative.
3) Set up an equidistant cylindrical map projection
axesm('MapProjection','eqdcylin')
setm(gca,'GlineStyle','-','Grid','on','Frame','on')
4) Draw a graticule with parallel and meridian labels at 60o intervals
setm(gca, 'MlabelLocation', 60,'PlabelLocation',[-30,30],...
'MlabelParallel','north','MeridianLabel','on',...
'ParallelLabel','on','MlineLocation',60,...
'PlineLocation',[-30,30])
5) Map de data using mesm and display with a color map legend

minigrid=[1,2,3,4,5,6;7,8,9,10,11,12;13,14,15,16,17,18]
minivec=[1/60,90,-180]

>> meshm(minigrid,minivec);
>> colorbar

SW SE
minigrid =
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18 NE
NW
5) Map de data using mesm and display with a color map legend
meshm(minigrid,minivec);
colormap('autumn');colorbar

minigrid =
-90,-180 SW 1 2 3 4 5 6 -90,180 SE
7 8 9 10 11 12
90,-180 NW 13 14 15 16 17 18 90,180 NE
Computing Map limits from reference vectors

load korea
refvec = 12.0000 45.0000 115.0000
[latlimits,longlimits]=limitm(map,refvec)
latlimits =
30 45
longlimits =
115 135

This means that korea region extends from 30oN to 45oN and 115oE to 135oE

>> [rows,cols]=size(map)
rows =
180
cols =
240
>> southlat=refvec(2)-rows/refvec(1)
southlat =
30.0000
>> eastlon=refvec(3)+cols/refvec(1)
eastlon =
135.0000
latitudes decrease southwards, longitudes increase eastwards
Geographic interpretation of matrix elements

>> load russia


>> [latlim,longlim]=limitm(map,refvec)
latlim =
35 80
longlim =
15 190
>> row=23;col=79;
[lat,long]=setltln(map,refvec,row,col)
lat =
39.5000
long =
30.7000
This means that the element row,column = 23,79 has this lat and long

>> [r,c]=setpostn(map,refvec,lat,long)
r=
23
c=
79
This means that this lat,long is in the 23,79 row coliumn
BUILDING A GEOREFERENCE MATRIX, R

Raster geodata is georeferenced in the toolbox through a companion data


structure called a referencing matrix. This 3-by-2 matrix of doubles
describes the scaling, orientation, and placement of the data grid on the
globe. For a given referencing matrix, R, one of the following relations holds
between rows and columns and coordinates (depending on whether the
grid is based on map coordinates or geographic coordinates, respectively):

[x y] = [row col 1] * R or [long lat] = [row col 1] * R

MAKEREFMAT Construct affine spatial-referencing matrix


A spatial referencing matrix R ties the row and column subscripts of an
image or regular data grid to 2-D map coordinates or to geographic
coordinates (longitude and geodetic latitude). R is a 3-by-2 affine
transformation matrix. R either transforms pixel subscripts (row, column)
to/from map coordinates (x,y) according to
[x y] = [row col 1] * R

or transforms pixel subscripts to/from geographic coordinates according to


[lon lat] = [row col 1] * R.
BUILDING A GEOREFERENCE MATRIX, R

To construct a referencing matrix for use with geographic coordinates,


use longitude in place of X and latitude in place of Y, as shown in the
third syntax below. This is one of the few places where longitude
precedes latitude in a function call.

R = MAKEREFMAT(X11, Y11, DX, DY) with scalar DX and DY constructs a


referencing matrix that aligns image/data grid rows to map X and
columns to map Y. X11 and Y11 are scalars that specify the map
location of the center of the first (1,1) pixel in the image or first
element of the data grid, so that

[X11 Y11] = pix2map(R,1,1).

DX is the difference in X (or longitude) between pixels in successive


columns and DY is the difference in Y (or latitude) between pixels in
successive rows. More abstractly, R is defined such that

[X11 + (col-1) * DX, Y11 + (row-1) * DY] = pix2map(R, row, col).


Mapping (MATLAB) georeferencing: makerefmat
Construct spatial referencing matrix of raster/grid files using command
makerefmat.m
Example 1
---------
Create a referencing matrix for an image with square, four-meter pixels
and with its upper left corner (in a map coordinate system) at
x = 207000 meters, y = 913000 meters. The image follows the typical
orientation: x increasing from column to column and y decreasing from
row to row.
x11 = 207002; % Two meters east of the upper left corner
y11 = 912998; % Two meters south of the upper left corner
dx = 4;
dy = -4;
R = makerefmat(x11, y11, dx, dy)
x11 = 207002; % Two meters east of the upper left corner
y11 = 912998; % Two meters south of the upper left corner
dx = 4;
dy = -4;
R = makerefmat(x11, y11, dx, dy)
R=
0 -4
4 0
206998 913002
Example 2
---------
Create a referencing matrix for a global geoid grid.

load geoid % Adds array 'geoid' to the workspace

% 'geoid' contains a model of the Earth's geoid sampled in


% one-degree-by-one-degree cells. Each column of 'geoid' contains
% geoid heights in meters for 180 cells starting at latitude
% -90 degrees and extending to +90 degrees, for a given latitude.
% Each row contains geoid heights for 360 cells starting at
% longitude 0 and extending 360 degrees.

lat11 = -89.5; % Cell-center latitude corresponding to geoid(1,1)


lon11 = 0.5; % Cell-center longitude corresponding to geoid(1,1)
dLat = 1; % From row to row moving north by one degree
dLon = 1; % From column to column moving east by one degree

geoidR = makerefmat(lon11, lat11, dLon, dLat)


% It's well known that at its most extreme the geoid reaches a
% minimum of slightly less than -100 meters, and that the minimum
% occurs in the Indian Ocean at approximately 4.5 degrees latitude,
% 78.5 degrees longitude. Check the geoid height at this location
% by using LATLON2PIX with the new referencing matrix:

[row, col] = latlon2pix(geoidR, 4.5, 78.5)


geoid(round(row),round(col))

geoidR =
0 1.0000
1.0000 0
-0.5000 -90.5000
row =
95
col =
79
ans =
-106.9260
Example 3
---------
Create a half-resolution version of a georeferenced TIFF image, using
Image Processing Toolbox functions IND2GRAY and IMRESIZE.

% Read the indexed-color TIFF image and convert it to grayscale.


% The size of the image is 2000-by-2000.
[X, cmap] = imread('concord_ortho_w.tif');
I_orig = ind2gray(X, cmap);

% Read the corresponding worldfile. Each image pixel covers a


% one-meter square on the map.
R_orig = worldfileread('concord_ortho_w.tfw')

% Halve the resolution, creating a smaller (1000-by-1000) image.


I_half = imresize(I_orig, size(I_orig)/2, 'bicubic');

% Find the map coordinates of the center of pixel (1,1) in the


% resized image: halfway between the centers of pixels (1,1) and
% (2,2) in the original image.
[x11_orig, y11_orig] = pix2map(R_orig, 1, 1)
[x22_orig, y22_orig] = pix2map(R_orig, 2, 2)
% Average these to determine the center of pixel (1,1) in the new
% image.
x11_half = (x11_orig + x22_orig) / 2
y11_half = (y11_orig + y22_orig) / 2
% Construct a referencing matrix for the new image, noting that its
% pixels are each two meters square.
R_half = makerefmat(x11_half, y11_half, 2, -2)
% Display each image in map coordinates.
figure;
subplot(2,1,1); h1 = mapshow(I_orig,R_orig); ax1 = get(h1,'Parent');
subplot(2,1,2); h2 = mapshow(I_half,R_half); ax2 = get(h2,'Parent');
set(ax1, 'XLim', [208000 208250], 'YLim', [911800 911950])
set(ax2, 'XLim', [208000 208250], 'YLim', [911800 911950])
% Mark the same map location on top of each image.
x = 208202.21;
y = 911862.70;
line(x, y, 'Parent', ax1, 'Marker', '+', 'MarkerEdgeColor', 'r');
line(x, y, 'Parent', ax2, 'Marker', '+', 'MarkerEdgeColor', 'r');
% Graphically, they coincide, even though the same map location
% corresponds to two different pixel coordinates.
[row1, col1] = map2pix(R_orig, x, y)
[row2, col2] = map2pix(R_half, x, y)
Mapping
Mapping
Introduction to MATLAB mapping Toolbox
Map projections
MATLAB mapping Toolbox and georeferencing

Laboratory exercises:
Plotting images and maps
Google map loader
Getting satellite data from internet
Representing results of a monitoring campaign

Romà Tauler (IDAEA, CSIC, Barcelona)


Reading images

IMREAD Read image from graphics file.


A = IMREAD(FILENAME,FMT) reads a grayscale or color image from the file
specified by the string FILENAME. If the file is not in the current
directory, or in a directory on the MATLAB path, specify the full
pathname.
The text string FMT specifies the format of the file by its standard
file extension. For example, specify 'gif' for Graphics Interchange
Format files. To see a list of supported formats, with their file
extensions, use the IMFORMATS function. If IMREAD cannot find a file
named FILENAME, it looks for a file named FILENAME.FMT.
The return value A is an array containing the image data. If the file
contains a grayscale image, A is an M-by-N array. If the file contains
a truecolor image, A is an M-by-N-by-3 array. For TIFF files containing
color images that use the CMYK color space, A is an M-by-N-by-4 array.
See TIFF in the Format-Specific Information section for more
information.

Look at C:\Archivos de programa\MATLAB\R2007a\toolbox\images\imdemos


for images and demos
..................................................
imformats
EXT ISA INFO READ WRITE ALPHA DESCRIPTION
------------------------------------------------------------------------------------------------
bmp isbmp imbmpinfo readbmp writebmp 0 Windows Bitmap (BMP)
cur iscur imcurinfo readcur 1 Windows Cursor resources (CUR)
fts fits isfits imfitsinfo readfits 0 Flexible Image Transport System (FITS)
gif isgif imgifinfo readgif writegif 0 Graphics Interchange Format (GIF)
hdf ishdf imhdfinfo readhdf writehdf 0 Hierarchical Data Format (HDF)
ico isico imicoinfo readico 1 Windows Icon resources (ICO)
jpg jpeg isjpg imjpginfo readjpg writejpg 0 Joint Photographic Experts Group (JPEG)
pbm ispbm impnminfo readpnm writepnm 0 Portable Bitmap (PBM)
pcx ispcx impcxinfo readpcx writepcx 0 Windows Paintbrush (PCX)
pgm ispgm impnminfo readpnm writepnm 0 Portable Graymap (PGM)
png ispng impnginfo readpng writepng 1 Portable Network Graphics (PNG)
pnm ispnm impnminfo readpnm writepnm 0 Portable Any Map (PNM)
ppm isppm impnminfo readpnm writepnm 0 Portable Pixmap (PPM)
ras isras imrasinfo readras writeras 1 Sun Raster (RAS)
tif tiff istif imtifinfo readtif writetif 0 Tagged Image File Format (TIFF)
xwd isxwd imxwdinfo readxwd writexwd 0 X Window Dump (XWD)
A=imread('moon.tif')
image(A)
imagesc(A)
50
;
100

150

200

250

300

350

400

450

500

50 100 150 200 250 300 350


Table: summary of supported image types
BMP 1-bit, 8-bit and 24-bit uncompressed images
imwrite(x,filename,fmt)
GIF 8-bit images
HDF 8-bit raster image datasets, with or without associated >> A=imread('moon.tif');
colormap; 24-bit raster image datasets; uncompressed or
with RLE or JPEG compression >> imagesc(A)
JPEG 8-bit, 12-bit, and 16-bit Baseline JPEG images
PBM Any 1-bit PBM image, ASCII (plain) or raw (binary) encoding. >>
PCX 8-bit images imwrite(A,'moon.jpeg','jpeg');
PGM Any standard PGM image. ASCII (plain) encoded with
arbitrary color depth. Raw (binary) encoded with up >> clear
to 16 bits per gray value.
PNG 1-bit, 2-bit, 4-bit, 8-bit, and 16-bit grayscale
>> A=imread('moon.jpeg');
images; 8-bit and 16-bit grayscale images with alpha
>> imagesc(A)
channels; 1-bit, 2-bit, 4-bit, and 8-bit indexed
images; 24-bit and 48-bit truecolor images; 24-bit
and 48-bit truecolor images with alpha channels
PNM Any of PPM/PGM/PBM (see above) chosen automatically
PPM Any standard PPM image. ASCII (plain) encoded with
arbitrary color depth. Raw (binary) encoded with up
to 16 bits per color component.
RAS Any RAS image, including 1-bit bitmap, 8-bit indexed,
24-bit truecolor and 32-bit truecolor with alpha
TIFF Baseline TIFF images, including 1-bit, 8-bit, 16-bit,
and 24-bit uncompressed images; 1-bit, 8-bit, 16-bit,
and 24-bit images with packbits compression; 1-bit
images with CCITT 1D, Group 3, and Group 4 compression;
CIELAB, ICCLAB, and CMYK images
XWD 8-bit ZPixmaps
...\m_map\private
A=imread('exlamber.gif');
image(A)
imagesc(A)
Mapping
Mapping
Introduction to MATLAB mapping Toolbox
Data Models
Map projections
MATLAB mapping Toolbox and georeferencing
Introduction to M_map Toolbox

Laboratory exercises:
Plotting images
Google maps and Google Earth
Getting satellite data from internet
Representing results of a monitoring campaign

Romà Tauler (IDAEA, CSIC, Barcelona)


LOADING A MAP AS AN IMAGE FROM GOOGLE MAPS
GEOREFERENCING IT AND PLOTTING VALUES
PLOTTING SYMBOLS ACCORDING THE SIZE OF A VARIABLE (E.G.
FLUORESCENCE)
EXAMPLE

Google map of the river region was read as a ‘7.tif’ file


GPS limits of the map are in gpslimit (aprox. from Google)
GPS positions of sampling pointys are in gpsxy
Values to represent are in variable z
All these variables have been stored in mapex.mat

>> load('mapex.mat')
>> whos
Name Size Bytes Class Attributes

gpslimit 2x2 32 double


gpsxy 62x2 992 double
sampnumbers 1x62 496 double
z 122x1 976 double
function mapdatagpsRT(gpslimit,gpsxy,sampnumbers,z)
% function mapdatagps(gpslimit);
% INPUT
% gpslimit=[lat1,long1;lat2,long2]
% lat1,long1 is right down corner
% lat2,long2 is left up corner
% example
gpslimit=[42.020003,2.426382;41.940318,2.217402];
% gpsxy are the GPS values where the representation
has to be performed
% gpsxy(lat,long)
% sampnumbers are sample numbers used for
representation
>> mapdatagpsRT(gpslimit,gpsxy,sampnumbers,z)

41.94

41.92

41.9

41.88

2.25 2.3 2.35 2.4

% scatter(y(i),x(i),(z(i)-min(z)+0.1)*100,[a,b,c],'.')
% scatter(y(i),x(i),(z(i)-min(z)+0.1)*20,'o','MarkerEdgeColor','k','MarkerFaceColor','c')

Test with different symbols, sizes and color….


Program plot_google_map

function varargout = plot_google_map(varargin)


% function h = plot_google_map(varargin)
% Plots a google map on the current axes using the Google Static Maps
API
%
% USAGE:
% h = plot_google_map(Property, Value,...)
% Plots the map on the given axes. Used also if no output is specified
%
% Or:
% [lonVec latVec imag] = plot_google_map(Property, Value,...)
% Returns the map without plotting it
%
% PROPERTIES:
% Height (640) - Height of the image in pixels (max 640)
% Width (640) - Width of the image in pixels (max 640)
% Scale (2) - (1/2) Resolution scale factor . using Scale=2 will
% double the resulotion of the downloaded image (up
% to 1280x1280) and will result in finer rendering,
% but processing time will be longer.
% MapType - ('roadmap') Type of map to return. Any of [roadmap,
% satellite, terrain, hybrid] See the Google Maps API for
% more information.
% Alpha (1) - (0-1) Transparency level of the map (0 is fully
% transparent). While the map is always
% moved to the bottom of the plot (i.e. will
% not hide previously drawn items), this can
% be useful in order to increase readability
% if many colors are ploted (using SCATTER
% for example).
% Language - (string) A 2 letter ISO 639-1 language code for displaying
labels in a local language instead of English (where available).
% For example, for Chinese use:
% plot_google_map('language','zh')
% For the list of codes, see:
% http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
% Marker - The marker argument is a text string with fields
% conforming to the Google Maps API. The
% following are valid examples:
% '43.0738740,-70.713993' (default midsize orange marker)
% '43.0738740,-70.713993,blue' (midsize blue marker)
% '43.0738740,-70.713993,yellowa' (midsize yellow
% marker with label "A")
% '43.0738740,-70.713993,tinyredb' (tiny red marker
% with label "B")
% Refresh (1) - (0/1) defines whether to automatically refresh the
% map upon zoom/pan action on the figure.
% OUTPUT:
% h - Handle to the plotted map
% lonVect - Vector of Longidute coordinates (WGS84) of the image
% latVect - Vector of Latidute coordinates (WGS84) of the image
% imag - Image matrix (height,width,3) of the map
% EXAMPLE - plot a map showing some capitals in Europe:
% lat = [48.8708 51.5188 41.9260 40.4312 52.523 37.982];
% lon = [2.4131 -0.1300 12.4951 -3.6788 13.415 23.715];
% plot(lon,lat,'.r','MarkerSize',20)
% plot_google_map
% References:
% http://www.mathworks.com/matlabcentral/fileexchange/24113
% http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
% http://developers.google.com/maps/documentation/staticmaps/
% Acknowledgement to Val Schmidt for his submission of
get_google_map.m
plot_google_map
% EXAMPLE - plot a map showing some capitals in Europe:
% lat = [48.8708 51.5188 41.9260 40.4312 52.523 37.982];
% lon = [2.4131 -0.1300 12.4951 -3.6788 13.415 23.715];
% plot(lon,lat,'.r','MarkerSize',20)

54

52

50

48

46

44

42

40

38

36
-5 0 5 10 15 20 25
plot_google_map

54

52

50

48

46

44

42

40

38

36
-5 0 5 10 15 20 25
>> axis([0,5,40,44]);
>> plot_google_map

44

43.5

43

42.5

42

41.5

41

40.5

40
0 1 2 3 4 5
>> axis([2,5,38,41]);
>> plot_google_map('maptype','roadmap');
>> plot_google_map('maptype','satellite');

41 41

40.5 40.5

40 40

39.5 39.5

39 39

38.5 38.5

38 38
1.5 2 2.5 3 3.5 4 4.5 5 5.5 1.5 2 2.5 3 3.5 4 4.5 5 5.5
>> load mapex
>> mapgoogle(gpsxy,sampnumbers,z)

42.04

42.02

42

41.98

41.96

41.94

2.24 2.26 2.28 2.3 2.32 2.34 2.36 2.38 2.4 2.42 2.44

Other possibilities???
Simple Google Map Loader in MATLAB.

GoogleMap.m and test1.m programs in subdirectory Google from lab_maps

Please, go to below link and then set your IP address in format of


http://code.google.com/apis/maps/signup.html
Key:
ABQIAAAAvHZo1sBQ73orGDJ_B0nzbxSIXsr6Ik0NwFLW01lZrR0IVF8WgxTDcvvnARCYU7qv5P59bACbpikqdw

Nord 42
Est 2.0
Simple Google Map Loader in MATLAB.

% Simple Google Map Loader in


MATLAB.
% Key:
% Please, go to below link and then set
your IP address in format of
% (http://xxx.xxx.xxx.xxx) for getting a
KEY!
%
http://code.google.com/apis/maps/signu
p.html
clc
clear all
key='ABQIAAAAteHND9YP6ctZEpCJs
GZpWxRQWo9-
sWXbVvdU2wQSDpuKctuXhBQYpf8M
m2875572Jwd2ge0XshBKBg';
pos='http://maps.google.com/staticmap
?center=42.0,2.0&zoom=8&size=512x5
12';
address=strcat(pos,'&key=',key);
[I map]=imread(address,'gif');
RGB=ind2rgb(I,map);
imshow(RGB);
Distribution of dissolved organic matter in freshwaters using
excitation emission fluorescence and Multivariate Curve Resolution
Xin Zhang, Rafael Marcé, Joan Armengol, Romà Tauler
Chemosphere 111 (2014) 120–128
Figure 1
Daug SEx-C STEm Emission
0.4

λEm 0.35

0.3

0.25

Loadings
0.2

λEx-C
D1 1 0.15

0.1

0.05

0
240 260 280 300 320 340 360 380 400 420 440
Wavelength (nm)

Emission MCR
ALS

λEx-C
D1
Excitation

D2 2
D D2

D3 SEx1-C1 new
SEx1-C1=C1 ⊗ SEx1
D4
λEx-C
D3
3
SVD
1 2 3 4 …… n
1 2 3 4 …… n
Dn Concentration
λEx-C

D4
4
1st component
0.18

0.16

0.14

0.12

……
0.1
……

0.08

0.06

0.04

440
0.02

420
0
0 20 40 60 80 100 120 140

400
Dn n
λEx-C

380 360
W avelength(nm)
320
300
280
260
240 340
0.3

0.25

0.2

0.15

0.1

0.05

0
Figure 2
a
Lo g
din

Excitation
3 components 0.4
MCR-ALS Ex
4 components0.4
MCR-ALS Ex
5 components
0.4
MCR-ALS Ex
6 components0.4
MCR-ALS Ex
0.35 MCR-ALS Em 0.35 MCR-ALS Em 0.35 MCR-ALS Em 0.35 MCR-ALS Em
PARAFAC Ex PARAFAC Ex PARAFAC Ex PARAFAC Ex
PARAFAC Em PARAFAC Em PARAFAC Em PARAFAC Em
0.3 0.3 0.3 0.3

0.25 0.25 0.25 0.25

Loadings

Loadings

Loadings

Loadings
0.2 0.2 0.2 0.2

0.15 0.15 0.15 0.15

0.1 0.1 0.1 0.1

0.05 0.05 0.05 0.05

0 0 0 0
240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440
Wavelength(nm) Wavelength(nm) Wavelength(nm) Wavelength(nm)
0.4 0.4 0.4 0.4
MCR-ALS Ex MCR-ALS Ex MCR-ALS Ex MCR-ALS Ex
0.35 MCR-ALS Em 0.35 MCR-ALS Em 0.35 MCR-ALS Em 0.35 MCR-ALS Em
PARAFAC Ex PARAFAC Ex PARAFAC Ex PARAFAC Ex
PARAFAC Em PARAFAC Em PARAFAC Em PARAFAC Em
0.3 0.3 0.3 0.3

0.25 0.25 0.25 0.25


Loadings

Loadings

Loadings

Loadings
0.2 0.2 0.2 0.2

0.15 0.15 0.15 0.15

0.1 0.1 0.1 0.1

0.05 0.05 0.05 0.05

0 0 0 0
240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440
Wavelength(nm) Wavelength(nm) Wavelength(nm) Wavelength(nm)
0.4 0.4 0.4 0.4
MCR-ALS Ex MCR-ALS Ex MCR-ALS Ex MCR-ALS Ex
0.35 MCR-ALS Em 0.35 MCR-ALS Em 0.35 MCR-ALS Em 0.35 MCR-ALS Em
PARAFAC Ex PARAFAC Ex PARAFAC Ex PARAFAC Ex
PARAFAC Em PARAFAC Em PARAFAC Em PARAFAC Em
0.3 0.3 0.3 0.3

0.25 0.25 0.25 0.25


Loadings

Loadings

Loadings

Loadings
0.2 0.2 0.2 0.2

0.15 0.15 0.15 0.15

0.1 0.1 0.1 0.1

0.05 0.05 0.05 0.05

0 0 0 0
240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440
Wavelength(nm) Wavelength(nm) Wavelength(nm) Wavelength(nm)
0.4 0.4 0.4
MCR-ALS Ex MCR-ALS Ex MCR-ALS Ex
0.35 MCR-ALS Em 0.35 MCR-ALS Em 0.35 MCR-ALS Em
PARAFAC Ex PARAFAC Ex PARAFAC Ex
PARAFAC Em PARAFAC Em PARAFAC Em
0.3 0.3 0.3

0.25 0.25 0.25


Loadings

Loadings

Loadings
0.2 0.2 0.2

0.15 0.15 0.15

0.1 0.1 0.1

0.05 0.05 0.05

0 0 0
240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440
Wavelength(nm) Wavelength(nm) Wavelength(nm)

0.4 0.4
MCR-ALS Ex MCR-ALS Ex
0.35 MCR-ALS Em 0.35 MCR-ALS Em
PARAFAC Ex PARAFAC Ex
PARAFAC Em PARAFAC Em
0.3 0.3

Loadings 0.25 0.25

Loadings
0.2 0.2

0.15 0.15

0.1 0.1

0.05 0.05

0 0
240 260 280 300 320 340 360 380 400 420 440 240 260 280 300 320 340 360 380 400 420 440
Wavelength(nm) Wavelength(nm)
0.4
MCR-ALS Ex
0.35 MCR-ALS Em
PARAFAC Ex

Figure 3
PARAFAC Em
0.3

0.25

Loadings
0.2

0.15

0.1

0.05

0
240 260 280 300 320 340 360 380 400 420 440
Wavelength(nm)
41.94

9
41.93

8
41.92

7
41.91

a 41.9
6

%Fmax
5
41.89

4
41.88

3
41.87

2
2.22 2.24 2.26 2.28 2.3 2.32 2.34 2.36 2.38 2.4 2.42
41.94
1
9 10 20 30 40 50 60
Stations
41.93
8

41.92
7

41.91
6

%Fmax
41.9
5

41.89
4

41.88
3

41.87
2

2.22 2.24 2.26 2.28 2.3 2.32 2.34 2.36 2.38 2.4 2.42
1
41.94
9 10 20 30 40 50 60
Stations
41.93 8

41.92 7

41.91 6

%Fmax
41.9
5

41.89 4

41.88 3

41.87 2

Figure 4 2.22 2.24 2.26 2.28 2.3 2.32 2.34 2.36 2.38 2.4 2.42 1
10 20 30
Stations
40 50 60
Lat 40.01 N, Lon 2.09 E

Lat 39.09 N, Lon 3.56 E


Producing map images (ex. from google earth) and georefencing them

Make a map of Cap Salines in >> R = MAKEREFMAT(39.15, 3.02,


Mallorca using Google Earth and store dlon, dlat)
in an image jpg file capsalines.jpg R=
0 0.0000
>> A=imread('capsalines2.jpg','jpg'); 0.0000 0
>> size(A) 39.1500 3.0200
ans =
758 1280 3
AI=A(end:-1:1,:,:);
>> latmin=39.1538
>> latmax=39.1612 mapview
>> lonmin=3.0221
>> lonmax=3.0327 Check for the correct georeferences
>> dlon=(lonmax-lonmin)/1280
>> dlat=(latmax-latmin)/758 Save image as a GeoTiff
It creates two files:
refvec=[1/dlon,39.1612,3.0327] one .tiff and another .tfw
refvec =
1.0e+005 * Now it can already be read directly as a
1.2075 0.0004 0.0000 GeoTiff referecned image for further
work
Google Earth
geoshow(AI,R)
>> refvec=[1/dlon,39.1612,3.0327]
refvec = 1.0e+005 * 1.2075 0.0004 0.0000
>> geoshow(AI,refvec)
Map Viewer
capsalines.tif, capsalines.tfw
Mapping
Mapping
Introduction to MATLAB mapping Toolbox
Data Models
Map projections
MATLAB mapping Toolbox and georeferencing
Introduction to M_map Toolbox

Laboratory exercises:
Plotting images
Google map loader
Getting satellite data from internet
Representing results from a monitoring campaign

Romà Tauler (IDAEA, CSIC, Barcelona)


Geeting satellite data from internet
Examples of satellite data manipulation
1. Global SST (or any variable on a global Lat/Long grid)
% NOAA/NASA Pathfinder AVHRR SST product
% http://podaac.jpl.nasa.gov/sst/

For example:
in subdirectory nasa from lab_maps
bsst2007.hdf
Use import bizard of MATLAB
Choose bsst
It is a matrix of dimensions 4096 8192
It can be represented directly using image

image(bsst)

But the units are not correct!


Georeferencing the map

To calculate the geographic location of a specific pixel use the following


equations for 9 km equal-angle imagery (other resolutions will be similar):

longitude = (-180. + (x * dx)) + (dx/2)


latitude = (90. - (y * dy)) - (dy/2)

where for 9km resolution: x = grid point in x-direction (0-4095); dx = grid x-


direction spacing (360 deg / 4096); y = grid point in y-direction (0-2047); and
dy = grid y-direction spacing (180 deg / 2048.)

for 5.0 4 km resolution: x = grid point in x-direction (0-8191); dx = grid x-


direction spacing (360 deg / 8192.); y = grid point in y-direction (0-4095); and
dy = grid y-direction spacing (180 deg / 4096.)

>> x=0:8192;
>> y=0:4095;
>> dx=360/8192;
>> dy=180/4096;
>> latitude = (90. - (y * dy)) - (dy/2);
>> longitude = (-180. + (x * dx)) + (dx/2);
Data Characteristics:
Parameter/Variable:

Sea Surface Temperature Variable Description/Definition:


SST - temperature of the sea surface.

Units of Measurement:
for version 4.1 and below pixel value with slope of 0.15 and y-intercept of -
3.0 to convert to °C.
for version 5.0 pixel value with slope of 0.075 and y-intercept of -3.0 to
convert to °C.

>> temp=bsst.*0.075-3;
>> imagesc(temp)
temp2=temp(1:4:4096,1:4:8192);
dx=360/8192
dy=180/4096
axesm Robinson
temp2=temp(1:4:4096,1:4:8192);
refmat2=makerefmat(-180,90,dx*4,-dy*4)
geoshow(temp2,refmat2,'DisplayType','texturemap')
gridm
Mapping
Mapping
Introduction to MATLAB mapping Toolbox
Data Models
Map projections
MATLAB mapping Toolbox and georeferencing
Introduction to M_map Toolbox

Laboratory exercises:
Plotting images
Google map loader
Getting satellite data from internet
Representing results from a monitoring campaign

Romà Tauler (IDAEA, CSIC, Barcelona)


PROYECTO ATOS (Julio 2007)
Deposición9 atmosférica de carbono y contaminates a los ecosistemas polares

N 20

15 18c
18a
16 3436a
3739a
39c42a
33a
33c 40 42c
15c
15a
10 14 21
20a 2830a
32
13 22 29
27b
12a
12c 2526b 31
23c
43b
44
11 23a 45
5 10
9c 46a
46c
6b789a 4849b

long
0
5b

-5
4b
longitud
80 ° -10
N 39
36
42
41
4019
18
17
34
35 3b
4330
32
2037
38
16
33
28
15
44
26
29
25
31
45 14
21 -15
46
471124
27
13
22
12 2b
49
48 23
-20 11b
910 10 20 30 40 50 60 70 80
78
6 Sample
Decluttered
5
82

39b 42c
1718b 33a
33c 38 4042a
3536b 43b
44
80 15c 20a
15a 21 2526b 2931
27b 46a
46c
4 11
13
12b 22
23a
23c
4849b
9b10
8
78 6b7
3 5b
70 °
N 76
latitud

latd
2 4b
74
3b
1 72

2b
70
30 ° ° E
W 20 11b
20 ° W ° 68
10 E 10 20 30 40 50 60 70 80
10 ° W °
0 Decluttered
Sample
PROYECTO ATOS (Julio 2007)
Deposición atmosférica de carbono y contaminates a los ecosistemas polares
group tasks:
North Pole
POP analysis in samples:
Higher Latd -air and aerosols
and long -sea-water
Ice
39
36 19
-Ice
42
41 18
17
35
40 38
34
37
16
-Fito- and zooplancton
33
28
30
32
43 20 15
44 26 Experiments:
Approximate 31 29
25 14
21
45
ice limit -fotodegradation
2427
-biodegradation (zoo)
46 13 -accumulation
22
12
48 47
49 23 -toxicity
11
Open
Method Implementation
sea -SBSE+TD+GC-MS
10
9
8 Data evaluation and
7
6 Integration
Example: CTD data evaluation and Integration

Buque Hespérides CTD

CTD= Conductivity, Temperature, Depth


and other sensors: salt and dissoved O2
conc., beam light transmission,
fluorescence, turbidimetry
Example: CTD data evaluation and Integration
El CTD proporciona medidas de 10 variables a diferentes profundidades en
cada una de las estaciones de parada del buque
10 variables 10 variables 10 variables

depths Estación depths Estación ......... depths Estación


(100,.. 1 ......... (100,… 20 (100,… 49
1000 m) 1000 m) 1000 m)

1 'press‘ or La adquisición de datos se realiza muy rápidamente de forma


depths continua por lo que se requiere realizar un promediado y filtrado
2 'temp' previo de los datos.
3 'cond'
4 'salt' Tabla o Matriz final de datos a procesar : X(53367x10)
5 'oxyg' provenientes de 81 experimentos CTD (49 estaciones con
6 'btra' algunas réplicas y profundidades diferentes, total 80 estac.)
7 'fluo'
8 'turb'
9 'long' Se seleccionan algunos casos de interés:
10 'latd' 1) Matrices X1(80,10) XDCM(80,10), X100(80,10)
respectivamente en superfície, al máximo fluor y a 100m prof.)
2) Matrices de fluorescencia Xfluor(80,200)
45
Depth (press) 7
Temperatures
27b
22
16 47 23c26a
40 6 23a 31
4b 18b 37
39a
27b 32 33c
35
1 9b 15b
16
35
17 32
5 9a 12a 18a 20b 25 39a40
35 9c 12c 15c 20a 33b 45
1b 30a 34 37 40 8 14
6a 7 30a 38
30 26a 4 5a6a 11 13 17 21 24
27a 33c 38 6c 29
14 29 6b 18b 44
3a
25 3b 20a 49b 3 26b
4a 11 15a 18a 21 26b
press

temp
6b 20b23a
33b
36a 45
20 9b 41 43c 2 28
12c 15c 39b 42a 43b
5a 10 24 33a 42c 48 4a
23b
2a 6c 9c 12b 13 28 42b 46c
15 9a 12a 22 43a 1 4b 18c 36a
2b 8 15b 23c 36b 46a
5b 1b
1 36b
10 44 0 3b
7 31
39c
5 -1 2a 39b
18c 2b 43a 4849b

0
AT THE -2
4142b 43c 46b
4749a

10 20 30 40 50 60 70 80 10 20 30 40 50 60 70 80

Decluttered
Sample
MAXIMUM Decluttered
Salt conc
Sample

Conductivity
36 FLUORESCENCE. 35.5

27b
35 22
89a9c 22 26a27b
23c26a
23a
35 6a 23a
16 20b 25
23c 35 37
32 33c
31 37 6b7 15b 31 39a40
34
9b 32 33c
35 4b5b 6c 12a 15a 18a
17 21 24 30a 33b 38
45
9a 12a 15b 16 10 12b
18a 20b 25 39a40 11 13 18b
33 8 9c 12c 20a 33b 45 34.5 15c 36a
7 14 15c 38 11b 26b
10 24 30a 39c
5a6a6c 11 13 17 21 29
32 6b 3a 44
18b 3b 36b

salt
44
cond

26b 34
31 47
2b 28 43a
43c
2a 49a
4a 46b
30 28 39b4142b 46a
46c 49b
4b 36a 33.5 42c
29 11b
36b
3b 18c
28 39c 33 48
39b 18c
27 2b 43a 47 49b
42c43c46a
42a 46c
48
26 32.5
10 20 30 40 50 60 70 80 10 20 30 40 50 60 70 80
Sample Sample
Decluttered Decluttered
420 95

Conc. O2 diss. 42b


42a
42c 2b3b
Beam transm.
39c
4749a

90 2a 4b 49b
400 39b
1b 43b 4a 6b 36b 40
17 27b
28 39a 45 48
2b3b 43c46a 1b 22 27a29
46b 6c 9b 18c 38
85
380 1 2a 36a 46c 9a 3436a
33b
4b 26b 8 33a 35
4a 7 33c
5b 30a 36b 32 42c
21 23c26a 39c 48 80 1 16 4446a
5a 11 23b 15b 46c
49b 15a 18a 25 30a
oxyg

13 24 9c 20b

btra
360 10 18a 49a 26b28 46b
12c18c 32 12a 14 15c 31
18b20b 33b 40 44 75 5a 21 23b 26a
12b 15c 10 12b
12c 39b
7 12a 14 17 25 38 5b 24
340 9c 33c 47
31 34 43a
6c89a 15a16 29 70 23c 41
15b 39a
6b 9b 35 37 23a
45
320 11
22 27a
27b
AT THE 65 42a 43c
43b
300
10 20 30 40
Sample
50 60 MAXIMUM
70 80
60
10 20 30 40
Sample
50 60 70 80
Decluttered Decluttered

50
FLUORESCENCE.
5b 23a 39b 42a43a 100
1112b
13 23c26a 43c
9c 12a
45 14 16 21
20b 24 31 46b 90 Turb. 39b
2526b
40 15c 30a 80
46c 23c
15a 23a
35 18a 35 37 42b
70 11 43c
20a 32 36a 26a 43b
30 23b 42a
15b 34 60 5b
8 44 41
9c 26b
fluo

25 45 12c 15c

turb
28 39a 50 1 5a 13 21 25
18c 33a
33c 12b 28 43a
20b 24
33b 46a 12a
20 9b
7 10 14 20a 31 33c
27a 40 1b 32
7 9b 15a16
22 29 40 8 27b 36a
15 38 15b 18a 33b35 42b 44
17 48 30 27a 37 46c
4b 27b 22 30a 39a
40 42c
36b 4a 6a 18b 45
17 18c
10 1 6a 46a
4a
1b 3b 6c
Int. Fluor. 39c 49b
4749a
20 2a 3b4b 6b
2b
48
36b 39c 49b
5 10
4749a
2a
0 2b
10 20 30 40 50 60 70 80 0
10 20 30 40 50 60 70 80
Sample Sample
Decluttered Decluttered
correlation in dcm (máximo de clorofila
máximo de fluorescencia)
Correlation Map, Variables in Original Order

10
1
2
3
4
5
6
7
8
9
0.8
1 'press'
1 0.6
2 'temp' 2
3 'cond' 3
0.4

4 'salt' 4
0.2

5 'oxyg' 5
0

6 'btra' 6 -0.2

7 'fluo' 7 -0.4

8 'turb' 8 -0.6

9 'long' 9
-0.8
10
10 'latd'
Scale Gives Value of R for Each Variable Pair
Eigenvalues and Cross-validation Results for yred11 Variables/Loadings Plot for yred11
3.5 0.5

3
PCA 0.4
temp cond
salt

0.3 long
latd
2.5

Loadings on PC 1 (39.52%)
fluo
0.2 turb
RMSECV, RMSEC

Principal Eigenvalue % Variance


2 0.1
Component of Captured press
Number Cov(X) This PC
1.5 0
--------- ---------- ----------
1 3.95e+000 39.52 -0.1
1 2 3.10e+000 31.00 (70.53) btra
3 1.54e+000 15.42 (85.95) -0.2

0.5 4 8.46e-001 8.46 (94.41)


-0.3
oxyg
0 -0.4
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
Principal Component Number Variable
Variables/Loadings Plot for yred11
Variables/Loadings Plot for yred11 0.5
0.5 fluo
fluo
0.4 turb
0.4 turb
oxyg
oxyg 0.3
0.3

Loadings on PC 2 (31.00%)
0.2 latd
Loadings on PC 2 (31.00%)

0.2 latd long


long
0.1
0.1

0
0

-0.1 -0.1
temp temp
cond
cond -0.2
-0.2 salt
salt
press press
-0.3 -0.3

-0.4 -0.4

-0.5 btra -0.5 btra


1 2 3 4 5 6 7 8 9 10 -0.4 -0.2 0 0.2 0.4 0.6
Variable Loadings on PC 1 (39.52%)
Samples/Scores Plot of yred11
5

42a 39b
43b
4
43c
41
43a Higher fluorescence
3 Higher dissolved O2 and turbidimetry
Scores on PC 2 (31.00%)

42c 11 23c
2 42b
46b 23a
46c 28 5b
26b 13
24 12c 23b
21 26a
1 46a 18c 5a 10 12b
15c Intermediate
36a 12a 31
Last samples 14
9c samples
44 20b
closer to the ice
0 48 30a 20a18a25
36b 15a
7 33a 15b
32 16
-1 8 33b 33c
Initial 49b 9a
39c 6c 18b
38 34 3537
samples 1
49a 29 45 9b
2b2a 3b1b 4a 17 40 39a
-2 3a 22 Higher
47 4b 6b 6a 27a Salt
Higher beam transmission
27b Conduct
-3 Temp
-5 -4 -3 -2 -1 0 1 2 3
Scores on PC 1 (39.52%)
Study of the fluorescence at different depths for multiple samples
100x2 deepths (CTD down and up)
Xfluor(80,200) 10
50

45

20 40
Fluorescence
35
30
at 425 nm excitation
80 stations 40
30

25 and 685 nm emission


50 20
(chlorophila fluorescence.)
15
60
10
70
5

80
60
60 50 100 150 200

50
50

40 40

30 30
Initial Last
20 stations20 stations

10 10

0 0
0 20 40 60 80 100 120 140 160 180 200 0 10 20 30 40 50 60 70 80
MCR-ALS resolution of 4 fluorescence patterns
0.35

CTD way down depths CTD way updepths


0.3
14
17
Multiple Items (see Legend)

0.25 14 26 1813
25
1620 272319 7
26
11 18 24
0.2 29 28 6
20 12
10 31 3841 29 11 5
23 3337 21
0.15 43
9 45 3631
4953 41 32 41
7 54 37
0.1 6 56 45
4 60 49
1 6468
0.05 605652
697377 6864
71 7883
8287919599 96928884807672
0
20 40 60 80 100 120 140 160 180 200
Decluttered Variable
0.25
14
15 max. fluor. 7
16
10
11 17
at low depth. 6
0.2
18
11
10 5
0.15
9 19 12

Row 3
8 1
13 4
7
0.1 6 20
5
3 21 14
1 15
22
0.05 2016
23
27
2419
MCR-ALS 2428 3935 27
474338 3126
42 505559 51
4651
C1 0
20
31
32
33
34
35
36
37
38
40
39
40
4144 53 61
60
6367
68
69
7074
71
72
73
75
76
77
78
79
80
80
81
82
83
84
8589
8790
91
92
93
94
9598
96
97
99
100
100
100
99
98
97
96
95
94
93
92
9188
90
89
87
86
85
84
83
82
81
120
78
80
7773
76
75
74
72
7167635955
70
69
140 160 180 200
Decluttered200 Variable
31

180
1112b
160 5b
14 23c
140 10
12a 15c
120
8
Column 3

5a 15a
9c 12c 16 44
100
13 15b
80
7
60 23b 46b
9b 22 43a
40
18c 23a 27a 42a
20 42b 45
6a
6b 18a 24
28 33a
37 43c 46a
6c
2a3a4a4b 1718b 20a 34
33b35 39a40 42c 46c49a
47 49b
0 11b 20b
21 25
26a
26b 29
30a32 33c 36a 39b39c
41
10 20 30 40 50 60 70 80
Decluttered Sample
0.35

0.3
14
17
0.25
1813
20 max. fluor. 19
0.2 21 At interm.depthts 20 12

Row 1
17
0.15 16 23
21
24 11
15 25
0.1
26 22 10
1427 23
0.05 9
28
MCR-ALS 13 30
3337414549
25 8
12
0 12345678910
11 535761
6266707478
68 808387919599
79 97
100
99
98 9288
9693 878379
78
77 62585450464238
75716763 3733
3532
31
30
29
28
27 7654321
C1 20 40 60 80 100
Variable
120 140 160 180 200
Decluttered

200

180 43b
42c
42a
160 23b
43c
41 43a
140
5a 39b
13 21
120
46c
Column 1

24 46b
12b 16
100 5b
11
10 39c
80 14
15c 20b 36a
60 31
9a 15b 20a 23a
23c 26b 33b
9c
8 9b 33a 45
40 28 4849b
18a 30a
6c 37
20 27b 33c 42b 44
6b
6a 12a 22 46a
3b 29 35
2a 4a 4749a
0 11b2b
3a 4b 7 1718b
18c 25
26a 32 34 36b3839a40
10 20 30 40 50 60 70 80
Decluttered Sample
0.25 26
25
23
28 max. fluor.
0.2 2429 28 22

31
at interm.-high depths
29
23 32 21
0.15
31

Row 2
22 20
34 19
32
0.1 21 33 18
35
35
20 37 17
0.05 38
36
39 38
MCR-ALS 19
18
40
44
39 16
741
47
C3 11
0 12345678910
12
13
1417
15
16 48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
6367
64
656872 7782
7376
94 84
83 89 99 9590 79 7368 62
61
60
59
58
57
56
55
54
5350
51
49
48
47
4642
44
43 15
14
13
129
11
10
20 40 60 80 100 120 140 160 180 200
Decluttered Variable

180
23a
160 14 25

140 26a
11 26b
120 20b
Column 2

100 15a 30a 35 37


5a 9c 18a20a
21 43c
80 12b 15b
5b 16 34

60 15c 27a 38 43b


28
29 32 39a 43a
8 27b
40 17 40 44 49b
6a 22 33b 45
4b
4a 18c 24
23b 31 42a 46a4749a
20 1 6c7 9b10
6b 36b 39b 48
3a 12c 18b
1b 3b 23c 36a 41
9a 13 33a
0 2b
2a 12a 39c 42b 46b
10 20 30 40 50 60 70 80
Decluttered Sample
0.2

0.18 38
3741
max. fluor.
0.16 33 42
43 at high depths
0.14 45 36
0.12 32 4853 4339 32
52 34
54

Row 4
0.1 31 45
56 47
60 29
0.08 30 59 49 28
29 62
64 5854
0.06 68 605652 27
15
16
10 28 697377 63 14
0.04 3 6 13 6864 11
8 27 7175 71 17
8186
848892 100 8884807672
MCR-ALS 0.02
15 26
96 989490
2521 10
18 9
0 16
17
18
19
20
2125
22
23 22
23 8765321
C4 20 40 60 80 100 120 140 160 180 200
Decluttered Variable
250

16

200

150
Column 4

15a

11 15c
100 10 15b 44
34
26b
32
35 39b
50 18c 25 27a 30a 39a
14 17 37 40 46b
89a 18a 26a27b
4b5b6a 22 33a
33c
1 20a 33b 38 47
1b 5a 6b6c7 9b 12a 21 24 29
28 36b 43a 46c
46a
4a 12c 43c 4849a
0 2a3a
2b3b 9c 13 23a
23b
23c 31 36a 41 42c 45
42a 49b
10 20 30 40 50 60 70 80
Decluttered Sample
SIMPLS Variance Captured and Statistics for yred11
Fluorescence PLS prediction from others 8

7.8

7.6
Linear regression model using
Partial Least Squares calculated with SIMPLS 7.4

RMSECV, RMSEC
Cross validation: random samples w/ 8 splits 7.2

Percent Variance Captured by Regression Model 7


-----X-Block----- -----Y-Block----- 6.8
Comp This Total This Total
6.6
---- ------- ------- ------- -------
6.4
1 29.00 29.00 76.95 76.95
6.2
2 38.72 67.72 2.51 79.46
6
1 2 3 4 5 6 7 8 9
Latent Variable Number

Variables/Loadings Plot for yred11 Variables/Loadings Plot for yred11


0.6 0.4
turb
0.3 turb
0.4
long latd

0.2
0.2 temp cond latd
Loadings on LV 1 (29.00%)

long
salt oxyg

Reg Vector for Y 1


0.1
0 oxyg
temp cond
0 salt
-0.2 press
-0.1 press

-0.4
-0.2
btra
-0.6 -0.3

-0.8 -0.4 btra


1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
Variable Variable
SIMPLS Variance Captured and Statistics for yred11
Fluorescence PLS prediction from others 14

Excluding beam transmission and turbidity 13.5

13

Linear regression model using 12.5

RMSECV, RMSEC
Partial Least Squares calculated with the SIMPLS
12
Cross validation: random samples w/ 8 splits
Percent Variance Captured by Regression Model 11.5

-----X-Block----- -----Y-Block----- 11
Comp This Total This Total
10.5
---- ------- ------- ------- -------
10
1 34.94 34.94 33.23 33.23
2 39.55 74.49 10.53 43.76 9.5
1 2 3 4 5 6 7
3 11.72 86.21 12.44 56.20 Latent Variable Number

Variables/Loadings Plot for yred11 Variables/Loadings Plot for yred11


0.6 2.5
salt
0.5 oxyg
cond
temp
0.4 2
Loadings on LV 3 (11.72%)

0.3

VIP Scores for Y 1


latd
0.2 oxyg 1.5
long

0.1

0 1

-0.1
press press
-0.2 0.5
temp cond

-0.3 long salt


latd
-0.4 0
1 2 3 4 5 6 7 1 2 3 4 5 6 7
Variable Variable
Representation of the fluorescence maxima
function mapatos(latlim,lonlim,latdr,longr,ident,y)
% function mapatos(latlim,lonlim,latdr,longr,ident,y)
%
mapatos([77,81],[2,19],latdr2(9:80,:),longr2(9:80,:),identc3(9:80,:),yred(9:80,6));

% worldmap of the desired lat and long, with the coast lines
worldmap(latlim,lonlim)
load coast
geoshow('landareas.shp', 'FaceColor', [0.15 0.5 0.15])
plotm(latdr,longr,'r--')
textm(latdr,longr+0.4,ident)
10 CTD measured variables:
scatterm(latdr,longr,y,y,'filled');
1 Depth, press
gridm on
2 Temperature, temp
3 Conductivity, cond
linem(latdr,longr,y);
4 Salt concentration, salt
5 Oxygent dissolved, oxyg
6 beam light transmission, btrm
7 fluorescence, fluor
8 turbidimetry, turb
9 latitude, latd
10 longitude, long
Fluoresc in dcm
81 ° N

90
42b
42c39a
39b
39c
42a36a
36b
41
40 35
34
38
37
43a 17
18a
18c
18b
4443c
43b 33c
33b
33a 16
30a
28
80 ° N 2526b
26a
32
20b
20a 15b
15c
15a
45 31 29 21
14 85

46a
46c
46b
24
27b
27a
49a
49b
48 47 13
22 80
12c
12b
12a
23a
23b
23c
79 ° N 11

10 75
9a9b
9c
8
7
78 ° N 6c
6b
6a
70

65
77 ° N°
2 E3 ° E ° ° °
° E 6° E17° E18 E19
4 E5 ° E 6 ° E
° ° ° ° ° ° ° °
E 7 E 8 E 9 E10 E11 E12 E13 E14 E15 1
Salt conc in dcm
81 ° N

35

39a
39b
39c
42a
42b
42c 36a
36b 34.8
41
40 35
34
38
37
43a 17
18a
18c
18b
4443c
43b 33c
33b
33a 16
30a
28
80 ° N 2526b
26a
32
20b
20a 15b
15c
15a
34.6
45 31 29 21
14
34.4
46a
46c
46b
24
27b
27a
49a
49b
48 47 13
22 34.2
12c
12b
12a
23a
23b
23c
79 ° N 11
34

33.8
10
9a9b
9c
8 33.6
7
78 ° N 6c
6b
6a
33.4

33.2

33
77 ° N
2 ° E3 ° E ° ° °
° E 6° E17° E18 E19
4 E5 ° E 6 ° E
° ° ° ° ° ° ° °
E 7 E 8 E 9 E10 E11 E12 E13 E14 E15 1
conduct in dcm
81 ° N
35

42b
42c39a
39b
39c
42a36a
36b 34
41
40 35
34
38
37
43a 17
18a
18c
18b
4443c
43b 33c
33b
33a 16
30a
28
80 ° N 2526b
26a
32
20b
20a 15b
15c
15a
45 31 29 21
14 33

46a
46c
46b
24
27b
27a 32
49a
49b
48 47 13
22
12c
12b
12a
23a
23b
23c
79 ° N 11
31

10 30
9a9b
9c
8
7
78 ° N 6c
6b
6a 29

28

27
77 ° N
2 ° E3 ° E ° ° °
° E 6° E17° E18 E19
4 E5 ° E 6 ° E
° ° ° ° ° ° ° °
E 7 E 8 E 9 E10 E11 E12 E13 E14 E15 1
diss oxyg in dcm
81 ° N
41

40
42b
42c39a
39b
39c
42a36a
36b
41
40 35
34
38
37
43a 17
18a
18c
18b
4443c
43b 33c
33b
33a 16 39
30a
28
80 ° N 2526b
26a
32
20b
20a 15b
15a
15c
45 31 29 21
14
38
46a
46c
46b
24
27b
27a
49a
49b
48 47 13
22 37
12c
12b
12a
23a
23b
79 ° N 11 23c
36

10 35
9a9b
9c
8
7 34
78 ° N 6c
6b
6a

33

32

77 ° N
2 ° E3 ° E ° °
° 18° E19 E
31
4 E5 ° E 6 ° °
E 7 ° E 8 ° E 9 ° E10° E11° E12° E13° E14° E15° E16 E17 E
beam transm in dcm
81 ° N

90
42b
42c39a
39b
39c
42a36a
36b
41
40 35
34
38
37
43a 17
18a
18c
18b
4443c
43b 33c
33b
33a 16
30a
28
80 ° N 2526b
26a
32
20b
20a 15b
15c
15a
45 31 29 21
14 85

46a
46c
46b
24
27b
27a
49a
49b
48 47 13
22 80
12c
12b
12a
23a
23b
23c
79 ° N 11

10 75
9a9b
9c
8
7
78 ° N 6c
6b
6a
70

65
77 ° N°
2 E3 ° E ° ° °
° E 6° E17° E18 E19
4 E5 ° E 6 ° E
° ° ° ° ° ° ° °
E 7 E 8 E 9 E10 E11 E12 E13 E14 E15 1
turbidimertry in dcm
81 ° N
90

39a
39b
39c
42a
42b
42c 36a
36b 80
41
40 35
34
38
37
43a 17
18a
18c
18b
4443c
43b 33c
33b
33a 16
30a
28
80 ° N 2526b
26a
32
20b
20a 15b
15c
15a
45 31 29 21
14 70

46a
46c
46b
24
27b
27a 60
49a
49b
48 47 13
22
12c
12b
12a
23a
23b
79 ° N 11 23c
50

10
9a9b
9c 40
8
7
78 ° N 6c
6b
6a 30

20

77 ° N 10
2 ° E3 ° E ° ° °
° 17° E18 E19 E
4 E5 ° E 6 ° ° ° ° ° °
E 7 E 8 E 9 ° E10° E11° E12° E13 E14 E15 E16 E
From vectors to raster (grids)

[Z, refvec] = geoloc2grid(latdr2(9:80,:),longr2(9:80,:),yred(9:80,7),cellsize);

load atosmaps
[Z, refvec] = geoloc2grid(latdr2(9:80,:),longr2(9:80,:),yred(9:80,7),0.1);
worldmap([77,81],[2,16])
From vectors to raster (grids)

function [Z,refvec]=mapgridatos(latlim,longlim,latw,longw,y,cellsize)
% function [Z,refvec]=mapgridatos(latlim,longlim,lat,long,y,cellsize)
close
[Z, refvec] = geoloc2grid(latw,longw,y,cellsize);
worldmap(latlim,longlim)
meshm(Z,refvec)
load coast
geoshow('landareas.shp', 'FaceColor', [0.15 0.5 0.15])
plotm(latw,longw,'k+','LineWidth',1)
linem([79.5,80.5],[2,18],'w--','LineWidth',3)
colorbar
From vectors to raster (grids)

meshm(Z,refvec)
From vectors to raster (grids)
>> load coast
>> geoshow('landareas.shp', 'FaceColor', [0.15 0.5 0.15])
From vectors to raster (grids)
plotm(latdr2(9:80,:),longr2(9:80,:),'k-','LineWidth',5)
colorbar
From vectors to raster (grids)

[Z,refvec]=mapgridatos([77,81],[2,16],latdr(9:80,:),longr(9:80,:),ydeep(9:80,2),0.1);
Investigation of Arctic and Antarctica spatial and depth patterns of sea
water in CTD profiles using chemometric data analysis.
Ewelina Kotwa, Silvia Lacorte, Carlos Duarte, Roma Tauler
Polar Science, in press

In this paper a comparative study of CTD (Conductivity-Temperature-


Depth) sensor using 2- and 3-way chemometric methods was performed
for exploratory analysis and spatial patterns discovery from two distinct
polar geographical areas: Arctic and Antarctic Seas. Results from the two
oceanographic expeditions taking place in July 2007 (Arctic) and February
2009 (Antarctica), spanning the areas of 68°N-81°N, 20°W-20°E and
60°S-70°S, 50°W-77°50´W respectively, will be presented
CTD data is obtained by standard sensor devices frequently used in
oceanographic research type of studies. These data sets can be arranged in 3-
way data structures (according to sea water depth, measured variables and
geographical sample location modes). Measured variables were collected
within the total number of 174 locations. Special importance was given to
correlation and possible prediction of fluorescence (mostly related to biological
activity), from other physical variables.

Data pre-processing together with outliers and missing values detection and
elimination strategies were applied before the actual exploratory data analysis
was performed. Classical and robust versions of common chemometric tools
such as PCA, PARAFAC, PLS and nPLS were applied for data exploration and
calibration, and MATLAB's mapping toolbox was used for results geo-
referencing and visualization.
Measured variables.
Control plots for predicted Fluorescence
values;
No ”full data” ”5,10,25,50,100m data”
of ROBPCA Classical PCA ROBPCA Classical PCA
PC
This Total This Total This Total This Total
PC PC PC PC
1 61,26 61,26 62,92 62,92 59.78 59.78 55.67 55.67
2 17,02 78,28 14,26 77,18 19.67 79.46 20.78 76.45
3 8,33 86,61 6,56 83,74 7.04 86.49 8.37 84.81

Variance explained (%) by different number of PCs for station-wise


unfolded “full” and “selected depth” data;
No. ”Full data” ”5,10,25,50,100m” ”5,10,DCM,50,100m”
of ROBPCA Classical PCA ROBPCA Classical PCA ROBPCA Classical PCA
PC
s This Total This Total This Total This Total This Total This Total
PC PC PC PC PC PC
1 61,64 61,64 52,2 52,2 50.98 50.98 50,04 50,04 50.07 50.07 50,10 50,10

2 23,44 85,09 30,96 83,16 34.33 85.31 32,30 82,34 34.43 84.51 33,03 83,13

3 7,11 92,19 8,29 91,46 6.29 91.60 8,79 91,13 5.95 90.46 8,80 91,93

Variance explained (%) by different number of PCs for 3


data sets: “full”, “selected data” and “DCM”;
Robust and Classical scores for full and DMC data sets for
3 component PCA model..
Classic PCA loading polt of PCs 1 and 2
4
Antarctic
Arctic Robust PCA loading polt of PCs 1 and 2
6
Antarctic
2
Arctic

-2

-4

-2

-6

-4

-8

-6

-10
-4 -2 0 2 4 6 8 10 12
-8
-5 0 5 10

PCA loadings 1 vs 2 for a) classical and b)


robust “depth” data;
PCs 1, 2 and 3

Pc1
10
PC2
PC3
8

-2

-4

-6

-8
0 20 40 60 80 100 120 140 160

PCA loadings 1, 2 and 3 for a) classical and b)


robust “depth” data;
Geo-map of 1st PC for a) Arctic Sea, b)
Antarctica
No. ”full” dta ”depth”-data
of Var. Core Iter. Time Var. Core Iter. Time
com expl. cons. expl. cons.
1 42,05 100 11 1,52 39.49 100 11 0,3
2 68,01 100 6 0,42 64.22 100 9 0,2
3 76.33 41,17 35 1,42 73.9 -194 9 2,8

Chosing amount of components in


PARAFAC model
PARAFAC Mode 2

0.5 Comp 1
Comp 2

0.4

0.3

0.2

0.1

-0.1

-0.2

-0.3

-0.4

1 2 3 4 5 6 7
Temp Cond. Salin. Oxy. Beamtr Fluor. Seaturb

Resolved PARAFAC modes: a) depth, b)


variables, c) locations
Geo-map of 2nd component for a) Arctic Sea, b) Antartctica
All variables Only phisical variables
L X-Block Y-Block X-Block Y-Block
V.
This Total This Total This Total This Total
1 48,55 48,55 62,60 62,60 52,48 52,48 20,83 20,83
2 32,50 81,05 9,37 71,97 39.91 92,40 4,27 25,10
3 10,47 91,52 9,62 81,60 7,60 100 0,07 25,17

Variance coverage by 3
components PLS

RMSEC and RMSECV for PLS model.

You might also like