(Re-)create a matrix of latitude and one of longitude knowing the 4 vertices , taking into account the earth curvature
조회 수: 4 (최근 30일)
이전 댓글 표시
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
John D'Errico
2023년 1월 28일
편집: John D'Errico
2023년 1월 28일
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.
답변 (1개)
Anshuman
2023년 4월 18일
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
Anshuman
2023년 4월 18일
편집: Anshuman
2023년 4월 18일
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);
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!