How to convert lat, long to x y for plotting on the map?

1 view (last 30 days)
I have an 14080*13624 .jpg image that is the country map.
also I know the lat and long of 4 corner of the map.
I have the lat and long of some other point that I want to scatter them on my map.
I used the code below but the result dosen't match the real position of points.
img = imread('map.jpg');
imshow(img);
hold on
%% Desiger point
lat = 32.778473;
lon = 51.648468;
h = 400;
%% center
lat0 = 31.8978;
lon0 = 53.6133;
h0 = 400;
%%
wgs84 = wgs84Ellipsoid;
[xEast,yNorth,zUp] = geodetic2enu(lat,lon,h,lat0,lon0,h0,wgs84);
pix_size_x = 14080/2;
pix_size_y = 13824/2;
stepx = (8.2281e+05)/pix_size_x;
stepy = (9.2292e+05)/pix_size_y;
x = pix_size_x + xEast/stepx;
y = pix_size_y - yNorth/stepy;
scatter(x,y)
axis equal
Would you please help me solve this problem?!
  5 Comments
Sabereh
Sabereh on 10 Oct 2022
@Walter Roberson yes,the divided by 2 is because of the refrence point is center.
Benjamin Thompson
Benjamin Thompson on 10 Oct 2022
If you have the Mapping Toolbox you can use makerefmat and latlon2pix.

Sign in to comment.

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!