需要引入的gis库:org.geotools、wcontour、org.opengis,直接上代码:
//创建测试数据
public List<InterpolData> createInterpolData() {
List<InterpolData> listData = new ArrayList<>();
double lon = 105.99;
double lat = 32.148;
double pValue = 60;
for (int i = 0; i < 50; i++) {
InterpolData interp = new InterpolData();
lon += Math.random();
lat += Math.random();
pValue += Math.random() * 50;
interp.setLon(lon);
interp.setLat(lat);
interp.setPValue(pValue);
listData.add(interp);
}
return listData;
}
//生成等值线或等值面
public FeatureCollection createequiSurface() {
SimpleFeatureCollection fc = createFeatureCl('');
Object geom = fc.features().next().getAttribute("the_geom");
WKTReader2 wktReader = new WKTReader2();
Geometry oldGeom = wktReader.read(geom.toString());
FeatureCollection pfeatureCol = null;
double _undefData = -9999.0;
List<PolyLine> cPolylineList;
List<Polygon> cPolygonList;
int width = 100, height = 100;
double[] _X = new double[width];
double[] _Y = new double[height];
double minX = fc.getBounds().getMinX();
double minY = fc.getBounds().getMinY();
double maxX = fc.getBounds().getMaxX();
double maxY = fc.getBounds().getMaxY();
Interpolate.createGridXY_Num(minX, minY, maxX, maxY, _X, _Y);
double[][] _gridData;
int nc =12;
double[] dataInterval = {
62, 65, 72, 75, 78, 81, 85, 90, 96, 100, 105, 110.9};
double[][] trainData = trainData(createInterpolData());
// IDW插值格网点
_gridData = Interpolate.interpolation_IDW_Neighbor(trainData,
_X, _Y, 12, _undefData);
int[][] S1 = new int[_gridData.length][_gridData[0].length

本文介绍了如何使用org.geotools、wcontour等GIS库进行数据处理,包括创建测试数据、生成等值线面,以及通过IDW插值和Contour算法实现地形拟合。
最低0.47元/天 解锁文章
3309





