java实现克里金插值导出geojson矢量数据(kriging)

生成效果

在现代科学研究中,数据的处理和分析是至关重要的一环。然而,我们往往会遇到数据缺失的情况,这时就需要使用插值方法来填补这些缺失值。其中,克里金插值法是一种常用的方法,在很多领域都有广泛的应用。

首先,克里金插值法在地质勘探领域中有着广泛的应用。在地质勘探中,我们需要研究地下的地质结构和矿藏分布情况。然而,在采集数据时,由于种种原因,我们无法获取到完整的数据集。这时,我们就可以使用克里金插值法来估算缺失的数据,从而更加准确地进行矿藏勘探和开采工作。

其次,克里金插值法在气象学领域中也有着重要的应用。在气象学中,我们需要预测未来的气象情况,比如温度、降雨量等。然而,由于气象数据的采集难度较大,数据缺失的情况也比较常见。这时,我们可以利用已有的气象数据,使用克里金插值法来预测缺失数据,从而更好地进行气象预测和防灾减灾工作。

除此之外,克里金插值法还在许多其他领域中得到了广泛的应用,比如环境监测、土地利用规划等。可以说,克里金插值法已经成为了数据处理和分析领域中不可或缺的一部分。

综上所述,克里金插值法在许多领域都有着广泛的应用,能够帮助我们更好地处理和分析数据,提高研究和预测的准确性。相信随着科学技术的不断发展,克里金插值法在更多领域中也将得到更加广泛和深入的应用。

一、控制类代码实现

 //http://localhost:8935/api/export/controlInterpolationVec?intv=0,30,50,70,90,150&trainfn=traindata.json&IM=Kriging
    @ApiOperation(value = "Interpolation")
    @GetMapping(value = "/controlInterpolationVec")
//    @Scheduled(cron = "0 10 * * * ?")
    public String stationInterpolationVec(String intv,String trainfn,String IM) {


        String traindt= FileUtils.ReadTxt(trainfn);

        int nNum = 3;
//        String monitorTime = DateUtil.format(DateUtil.addDateHours(new Date(),-1),"yyyy-MM-dd%20HH:00:00");
//        // 获取数据
//        JSONObject obj = JSON.parseObject(HttpUtils.sendGet(EDVRURL,"monitorTime=" + monitorTime + "&regionCode=370300"));
//        String re = HttpUtils.SendPostRain(adcd,btime,etime);
//        JSONObject obj = JSON.parseObject(re);
        JSONObject obj = JSON.parseObject(traindt);
//        JSONObject obj = JSON.parseObject("{\"png\":\"http://10.230.124.66:8080/group1/juece/20220520/15/26/8/aa7a2a7_.png\",\"text\":\"\",\"table\":[{\"Cnty\":\"两江新区\",\"Station_Name\":\"龙头寺公园\",\"qy\":\"中心城区\",\"Lon\":\"106.55\",\"lon\":\"106.55\",\"City\":\"市辖区\",\"Station_Id_C\":\"A9042\",\"SUM_PRE_1h\":\"44.8\",\"dvalue\":\"44.8\",\"Province\":\"重庆市\",\"Lat\":\"29.5833\",\"lat\":\"29.5833\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"石坪\",\"qy\":\"中心城区\",\"Lon\":\"106.6636\",\"lon\":\"106.6636\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7309\",\"SUM_PRE_1h\":\"44.1\",\"dvalue\":\"44.1\",\"Province\":\"重庆市\",\"Lat\":\"29.6658\",\"lat\":\"29.6658\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"玉峰山\",\"qy\":\"中心城区\",\"Lon\":\"106.7217\",\"lon\":\"106.7217\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7303\",\"SUM_PRE_1h\":\"42.6\",\"dvalue\":\"42.6\",\"Province\":\"重庆市\",\"Lat\":\"29.7208\",\"lat\":\"29.7208\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"龙兴\",\"qy\":\"中心城区\",\"Lon\":\"106.9\",\"lon\":\"106.9\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7075\",\"SUM_PRE_1h\":\"41.5\",\"dvalue\":\"41.5\",\"Province\":\"重庆市\",\"Lat\":\"29.7\",\"lat\":\"29.7\"},{\"Cnty\":\"两江新区\",\"Station_Name\":\"园博园\",\"qy\":\"中心城区\",\"Lon\":\"106.5486\",\"lon\":\"106.5486\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8172\",\"SUM_PRE_1h\":\"36.7\",\"dvalue\":\"36.7\",\"Province\":\"重庆市\",\"Lat\":\"29.6825\",\"lat\":\"29.6825\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"方家山村\",\"qy\":\"中心城区\",\"Lon\":\"106.5931\",\"lon\":\"106.5931\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8170\",\"SUM_PRE_1h\":\"35.5\",\"dvalue\":\"35.5\",\"Province\":\"重庆市\",\"Lat\":\"29.7525\",\"lat\":\"29.7525\"},{\"Cnty\":\"两江新区\",\"Station_Name\":\"悦来\",\"qy\":\"中心城区\",\"Lon\":\"106.5356\",\"lon\":\"106.5356\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7308\",\"SUM_PRE_1h\":\"35.1\",\"dvalue\":\"35.1\",\"Province\":\"重庆市\",\"Lat\":\"29.7322\",\"lat\":\"29.7322\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"学堂村\",\"qy\":\"中心城区\",\"Lon\":\"106.6233\",\"lon\":\"106.6233\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8168\",\"SUM_PRE_1h\":\"34.9\",\"dvalue\":\"34.9\",\"Province\":\"重庆市\",\"Lat\":\"29.7797\",\"lat\":\"29.7797\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"龙井\",\"qy\":\"中心城区\",\"Lon\":\"106.6644\",\"lon\":\"106.6644\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7292\",\"SUM_PRE_1h\":\"34.2\",\"dvalue\":\"34.2\",\"Province\":\"重庆市\",\"Lat\":\"29.6889\",\"lat\":\"29.6889\"},{\"Cnty\":\"两江新区\",\"Station_Name\":\"鸳鸯\",\"qy\":\"中心城区\",\"Lon\":\"106.5561\",\"lon\":\"106.5561\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7307\",\"SUM_PRE_1h\":\"31.9\",\"dvalue\":\"31.9\",\"Province\":\"重庆市\",\"Lat\":\"29.6686\",\"lat\":\"29.6686\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"龙山小学\",\"qy\":\"中心城区\",\"Lon\":\"106.4856\",\"lon\":\"106.4856\",\"City\":\"市辖区\",\"Station_Id_C\":\"A6100\",\"SUM_PRE_1h\":\"30.4\",\"dvalue\":\"30.4\",\"Province\":\"重庆市\",\"Lat\":\"29.59\",\"lat\":\"29.59\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"御临\",\"qy\":\"中心城区\",\"Lon\":\"106.8331\",\"lon\":\"106.8331\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7306\",\"SUM_PRE_1h\":\"30\",\"dvalue\":\"30\",\"Province\":\"重庆市\",\"Lat\":\"29.7106\",\"lat\":\"29.7106\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"大屋\",\"qy\":\"中心城区\",\"Lon\":\"106.7028\",\"lon\":\"106.7028\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7293\",\"SUM_PRE_1h\":\"29.9\",\"dvalue\":\"29.9\",\"Province\":\"重庆市\",\"Lat\":\"29.7592\",\"lat\":\"29.7592\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"约滨路\",\"qy\":\"中心城区\",\"Lon\":\"106.5178\",\"lon\":\"106.5178\",\"City\":\"市辖区\",\"Station_Id_C\":\"A6413\",\"SUM_PRE_1h\":\"29.8\",\"dvalue\":\"29.8\",\"Province\":\"重庆市\",\"Lat\":\"29.7003\",\"lat\":\"29.7003\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"永庆\",\"qy\":\"中心城区\",\"Lon\":\"106.7319\",\"lon\":\"106.7319\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7294\",\"SUM_PRE_1h\":\"29.6\",\"dvalue\":\"29.6\",\"Province\":\"重庆市\",\"Lat\":\"29.9383\",\"lat\":\"29.9383\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"大天池\",\"qy\":\"中心城区\",\"Lon\":\"106.9253\",\"lon\":\"106.9253\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8597\",\"SUM_PRE_1h\":\"28.5\",\"dvalue\":\"28.5\",\"Province\":\"重庆市\",\"Lat\":\"29.8308\",\"lat\":\"29.8308\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"秦家\",\"qy\":\"中心城区\",\"Lon\":\"106.6983\",\"lon\":\"106.6983\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7300\",\"SUM_PRE_1h\":\"28\",\"dvalue\":\"28\",\"Province\":\"重庆市\",\"Lat\":\"30.0683\",\"lat\":\"30.0683\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"梨园\",\"qy\":\"中心城区\",\"Lon\":\"106.6819\",\"lon\":\"106.6819\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7295\",\"SUM_PRE_1h\":\"27\",\"dvalue\":\"27\",\"Province\":\"重庆市\",\"Lat\":\"29.9619\",\"lat\":\"29.9619\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"良桥\",\"qy\":\"中心城区\",\"Lon\":\"106.6642\",\"lon\":\"106.6642\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8800\",\"SUM_PRE_1h\":\"26.8\",\"dvalue\":\"26.8\",\"Province\":\"重庆市\",\"Lat\":\"29.8503\",\"lat\":\"29.8503\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"新桥村\",\"qy\":\"中心城区\",\"Lon\":\"106.7056\",\"lon\":\"106.7056\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8175\",\"SUM_PRE_1h\":\"26.5\",\"dvalue\":\"26.5\",\"Province\":\"重庆市\",\"Lat\":\"29.7872\",\"lat\":\"29.7872\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"兴隆\",\"qy\":\"中心城区\",\"Lon\":\"106.7086\",\"lon\":\"106.7086\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7022\",\"SUM_PRE_1h\":\"26.1\",\"dvalue\":\"26.1\",\"Province\":\"重庆市\",\"Lat\":\"29.8972\",\"lat\":\"29.8972\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"老君山\",\"qy\":\"中心城区\",\"Lon\":\"106.9272\",\"lon\":\"106.9272\",\"City\":\"市辖区\",\"Station_Id_C\":\"A6351\",\"SUM_PRE_1h\":\"25.2\",\"dvalue\":\"25.2\",\"Province\":\"重庆市\",\"Lat\":\"29.7989\",\"lat\":\"29.7989\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"石船\",\"qy\":\"中心城区\",\"Lon\":\"106.8236\",\"lon\":\"106.8236\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7310\",\"SUM_PRE_1h\":\"25.1\",\"dvalue\":\"25.1\",\"Province\":\"重庆市\",\"Lat\":\"29.7664\",\"lat\":\"29.7664\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"麻柳沱\",\"qy\":\"中心城区\",\"Lon\":\"106.8811\",\"lon\":\"106.8811\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7305\",\"SUM_PRE_1h\":\"25\",\"dvalue\":\"25\",\"Province\":\"重庆市\",\"Lat\":\"29.8083\",\"lat\":\"29.8083\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"箭沱\",\"qy\":\"中心城区\",\"Lon\":\"106.8672\",\"lon\":\"106.8672\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7297\",\"SUM_PRE_1h\":\"24\",\"dvalue\":\"24\",\"Province\":\"重庆市\",\"Lat\":\"29.6633\",\"lat\":\"29.6633\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"同仁\",\"qy\":\"中心城区\",\"Lon\":\"106.7217\",\"lon\":\"106.7217\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7291\",\"SUM_PRE_1h\":\"23.2\",\"dvalue\":\"23.2\",\"Province\":\"重庆市\",\"Lat\":\"29.8658\",\"lat\":\"29.8658\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"华蓥山村\",\"qy\":\"中心城区\",\"Lon\":\"106.6764\",\"lon\":\"106.6764\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7315\",\"SUM_PRE_1h\":\"23.1\",\"dvalue\":\"23.1\",\"Province\":\"重庆市\",\"Lat\":\"30.0928\",\"lat\":\"30.0928\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"天池\",\"qy\":\"中心城区\",\"Lon\":\"106.8567\",\"lon\":\"106.8567\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8599\",\"SUM_PRE_1h\":\"22.4\",\"dvalue\":\"22.4\",\"Province\":\"重庆市\",\"Lat\":\"29.9836\",\"lat\":\"29.9836\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"杜家村\",\"qy\":\"中心城区\",\"Lon\":\"106.6944\",\"lon\":\"106.6944\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8174\",\"SUM_PRE_1h\":\"21.9\",\"dvalue\":\"21.9\",\"Province\":\"重庆市\",\"Lat\":\"29.9089\",\"lat\":\"29.9089\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"青龙村\",\"qy\":\"中心城区\",\"Lon\":\"106.8925\",\"lon\":\"106.8925\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8171\",\"SUM_PRE_1h\":\"21.7\",\"dvalue\":\"21.7\",\"Province\":\"重庆市\",\"Lat\":\"29.8767\",\"lat\":\"29.8767\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"龙安\",\"qy\":\"中心城区\",\"Lon\":\"106.8469\",\"lon\":\"106.8469\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7298\",\"SUM_PRE_1h\":\"21.5\",\"dvalue\":\"21.5\",\"Province\":\"重庆市\",\"Lat\":\"29.8919\",\"lat\":\"29.8919\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"沙湾\",\"qy\":\"中心城区\",\"Lon\":\"106.9242\",\"lon\":\"106.9242\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7289\",\"SUM_PRE_1h\":\"21.3\",\"dvalue\":\"21.3\",\"Province\":\"重庆市\",\"Lat\":\"29.7506\",\"lat\":\"29.7506\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"大面坡\",\"qy\":\"中心城区\",\"Lon\":\"106.7483\",\"lon\":\"106.7483\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7304\",\"SUM_PRE_1h\":\"21.3\",\"dvalue\":\"21.3\",\"Province\":\"重庆市\",\"Lat\":\"30.0181\",\"lat\":\"30.0181\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"统景\",\"qy\":\"中心城区\",\"Lon\":\"106.8333\",\"lon\":\"106.8333\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7023\",\"SUM_PRE_1h\":\"21.2\",\"dvalue\":\"21.2\",\"Province\":\"重庆市\",\"Lat\":\"29.85\",\"lat\":\"29.85\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"希望\",\"qy\":\"中心城区\",\"Lon\":\"106.77\",\"lon\":\"106.77\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8598\",\"SUM_PRE_1h\":\"21\",\"dvalue\":\"21\",\"Province\":\"重庆市\",\"Lat\":\"29.8189\",\"lat\":\"29.8189\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"天险洞\",\"qy\":\"中心城区\",\"Lon\":\"106.9358\",\"lon\":\"106.9358\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7311\",\"SUM_PRE_1h\":\"20.7\",\"dvalue\":\"20.7\",\"Province\":\"重庆市\",\"Lat\":\"29.8856\",\"lat\":\"29.8856\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"西新\",\"qy\":\"中心城区\",\"Lon\":\"106.8464\",\"lon\":\"106.8464\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8817\",\"SUM_PRE_1h\":\"20.1\",\"dvalue\":\"20.1\",\"Province\":\"重庆市\",\"Lat\":\"29.9514\",\"lat\":\"29.9514\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"黄印\",\"qy\":\"中心城区\",\"Lon\":\"106.8897\",\"lon\":\"106.8897\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7290\",\"SUM_PRE_1h\":\"19.6\",\"dvalue\":\"19.6\",\"Province\":\"重庆市\",\"Lat\":\"29.9658\",\"lat\":\"29.9658\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"高嘴\",\"qy\":\"中心城区\",\"Lon\":\"106.7861\",\"lon\":\"106.7861\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7301\",\"SUM_PRE_1h\":\"19.5\",\"dvalue\":\"19.5\",\"Province\":\"重庆市\",\"Lat\":\"29.9192\",\"lat\":\"29.9192\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"大湾\",\"qy\":\"中心城区\",\"Lon\":\"106.8419\",\"lon\":\"106.8419\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7313\",\"SUM_PRE_1h\":\"19.3\",\"dvalue\":\"19.3\",\"Province\":\"重庆市\",\"Lat\":\"29.8353\",\"lat\":\"29.8353\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"拱桥\",\"qy\":\"中心城区\",\"Lon\":\"106.7925\",\"lon\":\"106.7925\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7296\",\"SUM_PRE_1h\":\"19.3\",\"dvalue\":\"19.3\",\"Province\":\"重庆市\",\"Lat\":\"29.9917\",\"lat\":\"29.9917\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"大盛\",\"qy\":\"中心城区\",\"Lon\":\"106.9231\",\"lon\":\"106.9231\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7299\",\"SUM_PRE_1h\":\"19.1\",\"dvalue\":\"19.1\",\"Province\":\"重庆市\",\"Lat\":\"29.8972\",\"lat\":\"29.8972\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"古路\",\"qy\":\"中心城区\",\"Lon\":\"106.8419\",\"lon\":\"106.8419\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7133\",\"SUM_PRE_1h\":\"18.2\",\"dvalue\":\"18.2\",\"Province\":\"重庆市\",\"Lat\":\"29.8353\",\"lat\":\"29.8353\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"金凤村\",\"qy\":\"中心城区\",\"Lon\":\"106.7803\",\"lon\":\"106.7803\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8173\",\"SUM_PRE_1h\":\"17.3\",\"dvalue\":\"17.3\",\"Province\":\"重庆市\",\"Lat\":\"29.94\",\"lat\":\"29.94\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"硌碛\",\"qy\":\"中心城区\",\"Lon\":\"106.9444\",\"lon\":\"106.9444\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7076\",\"SUM_PRE_1h\":\"16.3\",\"dvalue\":\"16.3\",\"Province\":\"重庆市\",\"Lat\":\"29.7456\",\"lat\":\"29.7456\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"明月\",\"qy\":\"中心城区\",\"Lon\":\"106.8894\",\"lon\":\"106.8894\",\"City\":\"市辖区\",\"Station_Id_C\":\"A7312\",\"SUM_PRE_1h\":\"15.7\",\"dvalue\":\"15.7\",\"Province\":\"重庆市\",\"Lat\":\"29.9417\",\"lat\":\"29.9417\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"民权村\",\"qy\":\"中心城区\",\"Lon\":\"106.8681\",\"lon\":\"106.8681\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8169\",\"SUM_PRE_1h\":\"15.6\",\"dvalue\":\"15.6\",\"Province\":\"重庆市\",\"Lat\":\"29.9006\",\"lat\":\"29.9006\"},{\"Cnty\":\"渝北\",\"Station_Name\":\"华蓥山\",\"qy\":\"中心城区\",\"Lon\":\"106.6833\",\"lon\":\"106.6833\",\"City\":\"市辖区\",\"Station_Id_C\":\"A8013\",\"SUM_PRE_1h\":\"3.9\",\"dvalue\":\"3.9\",\"Province\":\"重庆市\",\"Lat\":\"30.05\",\"lat\":\"30.05\"}]}");
        JSONArray datalist = (JSONArray)obj.get("result");
        double[][] trainData = new double[datalist.size()][3];
        for (int i = 0; i < datalist.size(); i++) {
//            StationWithData data = datalist.get(i);
            trainData[i][0] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("longitude").toString());
            trainData[i][1] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("latitude").toString());
            trainData[i][2] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("v"));
        }
        //D:\gis\china
        String boundryFile ="yangpuxzqh.shp";
        int[] size = new int[]{400, 400};
        boolean isclip = true;
        String[] itv=intv.split(",");
        double[] dataInterval = new double[itv.length] ;
        for(int i = 0; i < itv.length; i++){
            dataInterval[i] = TransferDouble(itv[i]);
        }
        String strJson = InterpolationUtils.calEquiSurface(trainData, dataInterval, size, boundryFile, isclip,nNum,IM);
        return strJson;
    }

二、插值方法

/**
     * 用Kriging克里金法插值
     * Interpolation with kriging method
     *
     * @param SCoords discrete data array
     * @param X grid X array
     * @param Y grid Y array
     * @return interpolated grid data
     */
    public static double[][] interpolation_Kriging(double[][] SCoords, double[] X, double[] Y) {
        int rowNum, colNum;
        colNum = X.length;
        rowNum = Y.length;
        double[][] GCoords = new double[rowNum][colNum];
        int i, j;

        List<Point> points = new ArrayList<>();
        double[] Lons=new double[SCoords.length];
        double[] Lats=new double[SCoords.length];
        double[] Vals=new double[SCoords.length];
        for(int k=0;k<SCoords.length;k++){
            Lons[k]=SCoords[k][0];
            Lats[k]=SCoords[k][1];
            Vals[k]=SCoords[k][2];
            points.add(new Point(SCoords[k][0], SCoords[k][1], SCoords[k][2]));
        }
//        points.add(new Point(0, 0, 1));
        Kriging kriging = new Kriging(points, 0, 10, 10);


        //---- Do interpolation with IDW method
        for (i = 0; i < rowNum; i++) {
            for (j = 0; j < colNum; j++) {
//                Point p = new Point(X[j], Y[i], 0);
//                GCoords[i][j] = kriging.interpolate(p);
                double[][] lonl = {{X[j]}};
                double[][] latl =  {{Y[i]}};
                double[][] m = kriging.gridData(Lons, Lats, Vals, lonl, latl);
                GCoords[i][j]=m[0][0];

            }
        }

        //---- Smooth with 5 points
        double s = 0.5;
        for (i = 1; i < rowNum - 1; i++) {
            for (j = 1; j < colNum - 1; j++) {
                GCoords[i][j] = GCoords[i][j] + s / 4 * (GCoords[i + 1][j] + GCoords[i - 1][j] + GCoords[i][j + 1]
                        + GCoords[i][j - 1] - 4 * GCoords[i][j]);
            }

        }

        return GCoords;
    }

四、调用生成geojson

五、项目应用案例

如果对您有所帮助,请点赞打赏支持!

技术合作交流qq:2401315930