(Re-)create a matrix of latitude and one of longitude knowing the 4 vertices , taking into account the earth curvature
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dear all,
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!
Thanks!
2 Commenti
John D'Errico
il 28 Gen 2023
Modificato: John D'Errico
il 28 Gen 2023
What about the "matrix" are you trying to build? Just a set of coordinates of lattitude and longitude inside that quadrilateral region, but essentially where the edges are all great circles on the earth? Do you have the mapping toolbox? I would start there.
Risposte (1)
Anshuman
il 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
disp(lat);
disp(lon);
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!
3 Commenti
Anshuman
il 18 Apr 2023
Modificato: Anshuman
il 18 Apr 2023
You can also try to use the projectedCRS function in place of mapProjection:
% Create a projected coordinate reference system object for an equirectangular projection:
satelliteProjection = projectedCRS('Equirectangular', 'geographicCRS', geocrs('WGS 84'), 'geoid', refEllipsoid);
% Create a geographic coordinate reference object for the corners of the image:
imageGeographicCRS = geocrs('WGS 84', 'Degrees');
% Project the corners of the image to the equirectangular projection:
[xCorners, yCorners] = project(imageGeographicCRS, satelliteProjection, longitudeCorners, latitudeCorners);
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!