| | |
| | | return null; |
| | | } |
| | | |
| | | double[] values = new double[1]; |
| | | ds.GetRasterBand(1).ReadRaster(XY[0], XY[1], 1, 1, values); |
| | | double val = values[0]; |
| | | double[] vals = new double[1]; |
| | | ds.GetRasterBand(1).ReadRaster(XY[0], XY[1], 1, 1, vals); |
| | | |
| | | return isValid(val) ? val : null; |
| | | return isValid(vals[0]) ? vals[0] : null; |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return null; |
| | |
| | | * @return 像素坐标 |
| | | */ |
| | | public int[] coordinates2ColRow(double[] gt, double x, double y) { |
| | | int[] ints = new int[2]; |
| | | |
| | | // 向下取整,如果向上取整会导致计算结果偏大,从而在后面读取到邻近像元的数据 |
| | | //Double col = Math.floor(((y - gt[3]) * gt[1] - (x - gt[0]) * gt[4]) / (gt[5] * gt[1] - gt[2] * gt[4])); |
| | | Double col = Math.floor((y * gt[1] - x * gt[4] + gt[0] * gt[4] - gt[3] * gt[1]) / (gt[5] * gt[1] - gt[2] * gt[4])); |