Effacer les filtres
Effacer les filtres

How can we get the latitude and longitude of the pixels of a georeferenced image in MATLAB and put them in separate matrices?

17 vues (au cours des 30 derniers jours)
Georefrence image Get latitude &longitude ID telegram:@khodesalivan

Réponses (1)

Milan Bansal
Milan Bansal le 6 Juin 2024
Hi Hamed,
To obtain the latitude and longitude of the pixels of a georeferenced image in MATLAB and store them in separate matrices, you can follow these steps:
  1. Use readgeoraster to load the image and it georeference object.
  2. Use intrinsicToWorld function to get the map coordinates from the pixel coordinates.
  3. Use projinv function to compute the geo-coordinates from the map coordinates.
Please refer to the the example code given in the code snippet below to implement the same:
% Load the georeferenced image
imageFile = 'boston.tif';
[img, R] = readgeoraster(imageFile);
% Extract the raster size
rasterSize = size(img);
% Define the pixel coordinates
[x, y] = meshgrid(1:rasterSize(2), 1:rasterSize(1));
% Convert pixel coordinates to map coordinates
[XWorld, YWorld] = intrinsicToWorld(R, x, y);
% Convert map coordinates to geographic coordinates (latitude and longitude)
[lat, lon] = projinv(R.ProjectedCRS, XWorld, YWorld);
Please refer to the following documentation links to learn more about readgeoraster, intrinsicToWorld and projinv functions.
Hope it helps

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by