本人在arcgis中從栅格影像中任意選取代表點,但是隻能得到點的地理坐标(機關:米)。而代入MATLAB獲得該點資訊必須要得到該點的行列号。幾經周折,終于得到一畢業學長的提示,找到MATLAB中自帶的函數map2pix解決問題。現提供代碼如下,僅供各位參考:
%程式用于将arcgis中選點的地理坐标x,y轉化為栅格影像資料的行列值
clc,clear all;
%讀取影像坐标資訊
path1='C:\Users\hongLiang\Desktop\graph Of the Paper\tvdi - Band_1021.tfw';
R = worldfileread(path1);
%輸入代表點的地理坐标資訊
xArr=[337534.037000,418849.340000,293550.789000,434961.890000,250309.658000,579420.669000,376670.474000,489423.750000,...
348525.157000,271670.394000,278450.893000,395062.633000,295934.056000,295934.056000,456791.070000,414319.629000];
yArr=[3149544.901000,3135776.099000,2800939.887000,3261782.986000,3179205.782000,3191586.340000,2967300.524000,...
3197098.577000,2861594.128000,2760617.994000,2737525.636000,3170668.673000,3079553.702000,3079553.702000,3150314.340000,3231377.910000];
len=length(xArr);
for i=1:len
%用map2pix函數得到坐标點的行列值,但是得到的有負值,此處可以取個絕對值
[row,col] = map2pix(R,xArr(i),yArr(i));
%取絕對值
row=abs(row);col=abs(col);
%取整
row=round(row);col=round(col);
Col(i)=col;
Row(i)=row;
end