2016-09-27 177 views
0

我試圖使用scipy.interpolate.interp1d將經度和緯度值繪製爲地圖圖像的x座標和y座標像素。我有樣本值:Python scipy.interpolate.interp1d不適用於大浮點值

y = [0, 256, 512, 768, 1024, 1280, 1536] 
lat = [615436414755, 615226949459, 615017342897, 614807595000, 614597705702, 614387674936, 614177502635] 
x = [0, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304] 
lon = [235986328125, 236425781250, 236865234375, 237304687500, 237744140625, 238183593750, 238623046875, 239062500000, 239501953125, 239941406250] 

當我通過像這樣的功能:

xInterpolation = interp1d(xDegree, xPixel) 
    yInterpolation = interp1d(yDegree, yPixel) 

    return (int(xInterpolation(lon)),int(yInterpolation(lat))) 

我得到的值錯誤:

ValueError("A value in x_new is above the interpolation " ValueError: A value in x_new is above the interpolation range.

不管我什麼價值,它拋出價值錯誤,我甚至嘗試給出輸入列表中相同的緯度或經度值,但這也不起作用。有人知道這裏發生了什麼嗎?或者如果我使用錯誤的插值。

回答

1

interp1ddocs

bounds_error : bool, optional If True, a ValueError is raised any time interpolation is attempted on a value outside of the range of x (where extrapolation is necessary). If False, out of bounds values are assigned fill_value. By default, an error is raised.

所以,有些你的內插數據高於插值界。你試圖推斷,而不是插值。

當您使用插值像

xInterpolation = interp1d(xDegree, xPixel) xInterpolation(lon)

lon所有值必須屬於區間[xDegree.min, xDegree.max]

所以,你需要糾正你的數據插值或使用extrapolation

+0

不,它不在插值範圍之上。我已經仔細檢查過,並在問題中提到了這條信息。 – Omayr

+0

@Omayr那麼,你可以給你的問題提供所有陣列的樣本嗎? – ShabashP