Display small images on certain x and y (coordinates)

16 Ansichten (letzte 30 Tage)
BN
BN am 13 Apr. 2020
Kommentiert: Adam Danz am 14 Apr. 2020
Hello everyone,
I have 3 images that I want to plot each one in a certain x and y (latitude and longitude) coordinates. The latitude and longitude of each one are presented in a table.
In fact, I want to plot them on the existing figure (adding them) by 0.24 inches of height and 0.24 inches of weight for each of these 3 images. Since these images show the location of the 3 climate stations in the study region. Here is my current figure (I insert all of the code):
% read tif file
[A,R] = readgeoraster('DEM_30s.tif', 'OutputType', 'double');
low_single = typecast(uint8([255 255 127 255]), 'single');
mask = low_single==A;
A = A - min(A(~mask), [], 'all');
% creating colormap changing from white to brown as shown in image in the question
brown_color = [0.8 0.2 0.1];
light_brown = [0.95 0.9 0.8];
t = linspace(0, 1, max(A,[],'all'))';
cmap = t.*brown_color + (1-t).*light_brown;
gs = geoshow(A, cmap, R);
gs.CData(repmat(mask,1,1,3)) = 255;
axis equal
box on
xticks(44:1:65);
yticks(24:1:45);
ax = gca
xlim(ax, xlim(ax)+range(xlim(ax))*[-.02, .02]) % add 2% of space to the left and right of the x limit
Here is the results:
It is possible to add images on it using this code:
hold on
[img, ~, tr] = imread('img1.png');
im = image('CData',flipud(img),'XData',[50 51],'YData',[35 36]);
im.AlphaData = tr;
hold off
But the problem is I want to use the coordinate table that I attached, to add on the existing figure (no change XData and YData manually) and have all small images in 0.24 inches height and weight. So if anyone can tell me what I should do I would be so grateful. I have more than 100 images and 100 corresponding coordinates and these 3 just for example that I cliped from original table.
I attached all 3 small images and the coordinate table. Also, tif file uploaded here my google drive.
Thank you so much ?

Akzeptierte Antwort

Adam Danz
Adam Danz am 13 Apr. 2020
Bearbeitet: Adam Danz am 13 Apr. 2020
Check out the documentation for image(x,y,C)
In short, you need to calculate the [x1,x2], [y1,y2] coordinates where (x1,y1) is the lower left corner and (x2,y2) is the upper right corner.
The coordinates will be in data units so you won't be able to specify the size in inches. Once you decide which size is best, compute the corner coordinates you just need to use the data from your coordinates table which are the centers of the image and +/- 1/2 the width and height. Since you're already using axis equal you don't have to worry about aspect ratio problems.
If you get stuck, share what you've got and we can help get you over the hump.
  7 Kommentare
BN
BN am 14 Apr. 2020
I am really thank you, I successfully done it for one point.
I used lat/lon +-((4/10)/2)
And this modification:
hold on
[c, ~, tr] = imread('img1.png');
im = image (img1_lon,img1_lat,flipud(c));
im.AlphaData = tr;
Thank you again
Best Regards

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by