필터 지우기
필터 지우기

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

조회 수: 17 (최근 30일)
Georefrence image Get latitude &longitude ID telegram:@khodesalivan

답변 (1개)

Milan Bansal
Milan Bansal 2024년 6월 6일
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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by