Geoscience Reference
In-Depth Information
can be used to extract the geodetic coordinates of the four corners of the
image. h is information is contained in the header of the HDF i le. Having
launched the HDF tool, we select on the uppermost directory called
naivasha.hdf
and i nd a long list of i le attributes in the upper right panel of
the GUI, one of which is
productmetadata.0
, which includes the attribute
scenefourcorners
. We collect the coordinates of the four scene corners into a
single array
inputpoints
:
inputpoints(1,:) = [36.214332 -0.319922]; % upper left corner
inputpoints(2,:) = [36.096003 -0.878267]; % lower left corner
inputpoints(3,:) = [36.770406 -0.400443]; % upper right corner
inputpoints(4,:) = [36.652213 -0.958743]; % lower right corner
It is important to note that the coordinates contained in
productmetadata.0
need to be l ipped in order to have
x
=
longitudes
and
y
=
latitudes
. h e four
corners of the image correspond to the pixels in the four corners of the
image, which we store in a variable named
basepoints
.
basepoints(1,:) = [1,1]; % upper left pixel
basepoints(2,:) = [1,4200]; % lower left pixel
basepoints(3,:) = [4100,1]; % upper right pixel
basepoints(4,:) = [4100,4200]; % lower right pixel
h e function
fitgeotrans
now takes the pairs of control points,
inputpoints
and
basepoints
, and uses them to infer a spatial transformation matrix
tform
.
tform = fitgeotrans(inputpoints,basepoints,'affine');
We next determine the limits of the input for georeferencing (i.e., of
the original image
naivasha_rgb
) using
size
, which yields
xLimitsIn
and
yLimitsIn
. Adding a value of 0.5 to both
xLimitsIn
and
yLimitsIn
prevents the
edges of the image from being truncated during the ai ne transformation.
We then determine the limits of the output (i.e. of the georeferenced image,
which is subsequently called
newnaivasha_rgb
) using
outputLimits
, which
yields
XBounds
and
YBounds
.
xLimitsIn = 0.5 + [0 size(naivasha_rgb,2)];
yLimitsIn = 0.5 + [0 size(naivasha_rgb,1)];
[XBounds,YBounds] = outputLimits(tform,xLimitsIn,yLimitsIn);
We then use
imref2d
to reference the image to a world (or global) coordinate
system.
Rout = imref2d(size(naivasha_rgb),XBounds,YBounds);
An
imref2d
object encapsulates the relationship between the intrinsic
coordinates anchored to the rows and columns of the image, and the spatial