Converting pixel coordinates to latitude and longitude in decimal degrees for a binary image.

12 visualizaciones (últimos 30 días)
How can I convert the centroid of the pixel coordinates into latitude and longitude values in decimal degrees ?I have used several functions like Utm2deg and utm2ll for doing the same after converting the pixels coordinates to UTM but it does not give any result.I am attaching the code here.It will be helpful if someone can help me with it as I am a novice in matlab.
A= geotiffread("img.tif');
r = regionprops('table',l,'centroid',);
x_centroid= r.Centroid;
y_centroid= r.Centroid;
R=makerefmat(885698,1258968,200,200);
[lat, lon] = pix2latlon(R,x_centroid,y_centroid);
Thanks in Adavance!
  4 comentarios
darova
darova el 22 de Oct. de 2019
What are boudaries of images (lat/long)?
Maybe this data can be used for scaling?
RasterExtentInWorldX: 20820
RasterExtentInWorldY: 17790
darova
darova el 23 de Oct. de 2019
You want to scale your data?
[m,n,~] = size(A); % size in pixels
xx = Left + (Right-Left)/n*x_centroid; % worlds coordinates
yy = Bottom + (Top-Bottom)/m*y_centroid;

Iniciar sesión para comentar.

Respuestas (1)

darova
darova el 23 de Oct. de 2019
You forgot about concantenating (cat) function
A= geotiffread('ems_a&n_subset.tif');
A(A>=0.99500)=0;
y = im2bw(A);
r = regionprops(y,'Centroid');
xy = cat(1,r.Centroid);
imshow(y)
hold on
plot(xy(:,1),xy(:,2),'or')
hold off
r.Centroid returns an asnwer as a structure not an array
>> r.Centroid
ans =
163.5000 235.0000
ans =
518.5882 368.7059
  2 comentarios
darova
darova el 23 de Oct. de 2019
Did you try to express x and y?
lng = (x * radian - 135/180*pi) * earth_radius; %[km]
x = 1/radian*(lng/earth_radius + 135/180*pi)
lat = atanh(sin(y)) * earth_radius; %[km]
y = asin(tanh(lat/earth_radius))

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by