在我的反應應用程式中,我使用中心緯度-經度、高度和寬度對影像進行了地理標記。單擊影像時,我會在單擊的位置獲得 xy 坐標(影像的像素)。
我想從影像的中心 lat-lon 和 x,y 像素計算可能的 lat-lon 坐標。
有沒有辦法做到這一點?有人請幫忙。
提前致謝 !
uj5u.com熱心網友回復:
根據上面的評論,如果你有一個 1 像素 = 1cm 的比例(這似乎很小,如果你有一個 4000x2100px 的影像,意味著你大約是 40 米 x 21 米)
然后計算滑鼠的 xy 位置的單擊或懸停時的緯度:
const R = 6378160; // Earth Radius in meters
const scale = 0.01; ( in meters 1cm = 0.01m per pixel )
const midX = imageWidth / 2;
const midY = imageHeight / 2;
const dX = x - midX; // Difference for x position in pixel;
const dY = y - midY; // Difference for y position in pixel;
// Get the difference in meters
const dXScaled = dX * scale;
const dYScaled = dY * scale;
// Convert the difference in latitude, longitude
const dLat = ( dXScaled / R ) * Math.PI / 180;
const dLon = ( dYScaled / (R*Cos(Math.PI *lat/180))) * Math.PI / 180;
// Return new position
return {
lon: lon dLon,
lat: lat dLat,
}
您可以使用此https://scienceweb.whoi.edu/marine/ndsf/cgi-bin/NDSFutility.cgi?form=0&from=XY&to=LatLon驗證上述答案(如果上面有錯誤,請告訴我我會正確的 )
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/497126.html
