• caorui521
    了解作者
  • Python
    开发工具
  • 547KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2021-04-12 20:12
    上传日期
基于pykrige的二维数据插值,pythion实现散乱点的插值
kriging.zip
内容介绍
""" Universal Kriging Example ========================= In this example we apply a regional linear trend to the kriging system. """ from pykrige.uk import UniversalKriging import numpy as np import matplotlib.pyplot as plt import os import numpy as np import pclpy from pclpy import pcl def read_pcd(filepath): lidar = [] with open(filepath, 'r', encoding='utf-8') as f: line = f.readline().strip() while line: linestr = line.split(" ") if len(linestr) == 4: linestr_convert = list(map(float, linestr)) lidar.append(linestr_convert) line = f.readline().strip() return np.array(lidar) data = np.array( [ [0.3, 1.2, 0.47], [1.9, 0.6, 0.56], [1.1, 3.2, 0.74], [3.3, 4.4, 1.47], [4.7, 3.8, 1.74], ] ) gridx = np.arange(0.0, 5.5, 0.5) gridy = np.arange(0.0, 5.5, 0.5) ############################################################################### # Create the universal kriging object. Required inputs are the X-coordinates of # the data points, the Y-coordinates of the data points, and the Z-values of the # data points. Variogram is handled as in the ordinary kriging case. # drift_terms is a list of the drift terms to include; currently supported terms # are 'regional_linear', 'point_log', and 'external_Z'. Refer to # UniversalKriging.__doc__ for more information. UK = UniversalKriging( data[:, 0], data[:, 1], data[:, 2], variogram_model="linear", drift_terms=["regional_linear"], ) ############################################################################### # Creates the kriged grid and the variance grid. Allows for kriging on a rectangular # grid of points, on a masked rectangular grid of points, or with arbitrary points. # (See UniversalKriging.__doc__ for more information.) data1 = read_pcd(r'E:/数据/DATA/DATA1/leftPcd.pcd') z, ss = UK.execute("grid",gridx,gridy) plt.imshow(z) plt.show()
评论
    相关推荐