(Re-)create a matrix of latitude and one of longitude knowing the 4 vertices , taking into account the earth curvature
5 views (last 30 days)
I wonder if the below can be implemented in MATLAB (or at all).
I have got a satellite image (Z). Z is a matrix of 2000 x 2048. I need to create two matrices, one of longitude and one of latitude, both having the same size of Z (2000 x 2048).
The information I have got to build this matrices are:
Matrix Latitude corners = [47.326; 41.832; 29.8886; 25.460]
Matrix Longitude corners = [3.769; 39.255; 2.226; 30.709]
Reference Ellipsoid Model = WGS84
I have tried several interpolation approaches, but of course, none of them takes into consideration the Earth curvature. Any help would be appreciated!
Anshuman on 18 Apr 2023
You can create the latitude and longitude matrices using the above information by using MATLAB mapping Toolbox to convert between different coordinate systems and projections.
Here is an example code snippet:
% Load the Mapping Toolbox
% i am assuming you already have the Mapping toolbox or you can install it
% by typing "matlab.addons.install" in the cmd window of MATLAB
% Define the image size
imageSize = [2000, 2048];
% Define the latitude and longitude corners in geographic coordinates
latitudeCorners = [47.326; 41.832; 29.8886; 25.460];
longitudeCorners = [3.769; 39.255; 2.226; 30.709];
% Define the reference ellipsoid model
refEllipsoid = wgs84Ellipsoid();
% Define the projection for the satellite image
satelliteProjection = mapProjection('Equirectangular', 'geoid', refEllipsoid);
% Define the X and Y limits for the image
xLimits = [1, imageSize(2)];
yLimits = [1, imageSize(1)];
% Convert the latitude and longitude corners to projected coordinates
[xCorners, yCorners] = project(satelliteProjection, latitudeCorners, longitudeCorners);
% Create grids of X and Y coordinates
[X, Y] = meshgrid(linspace(xLimits(1), xLimits(2), imageSize(2)), ...
linspace(yLimits(1), yLimits(2), imageSize(1)));
% Convert the X and Y coordinates to latitude and longitude
[lat, lon] = inverse(satelliteProjection, X, Y);
% Display the latitude and longitude matrices
The project and inverse functions are used to convert between geographic coordinates and projected coordinates, taking into account the curvature of the earth.
Hope it helps!