2016-09-27 129 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