DEM挖填方分析--基于水平参考面计算
基于水平參考高程面計算挖填方比較簡單,水平參考高程也就是某一個高程值,只需要計算同一位置上DEM高程到參考面高程即可,挖填方分析實際上就是計算DEM數據與參考面構成的封閉體體積。
DEM數據本身是由一系列等間距橫向和縱向分布的高程點構成,其數據組成形式與一般圖像類似,相當于每個圖像坐標上由像素值變成高程值。一般tif格式DEM數據還附帶一個tfw文件用以描述起始點坐標、橫向和縱向間隔距離等信息,通過讀取tfw文件可以更方便的計算DEM數據。
由于DEM數據為離散的高程數據,為了得到更精確的計算結果,需要對DEM數據進行內插,在DEM內部內插出更多的高程點形成更小的高程格網,以每個格網內高程點作為附近區(qū)域平均高程與參考面高程計算差值,并計算體積。當差值為正,此時需要將高出參考面部分挖去,差值即為需要挖掉的深度,通過差值與高程點所在格網面積計算的體積即為該格網處的挖方;當差值為負,此處高程低于參考面,需要進行填方計算,通過同樣方式計算填方量。
整個實現過程主要分為三步:
第一步,讀取DEM數據,獲取每一個柵格的高程值,讀取tfw文件,獲取起始坐標和每一個柵格長度;
Tfw文件內容:
第二步,對DEM高程值進行內插計算,將每一個柵格分割為n*n的格網,通過雙線性內插計算得到格網上每個點的高程值;
第三步,將每個格網上的高程值與參考面高程計算差值,通過單個格網面積計算得到挖填方結果。
具體實現:
public DigFillResultData analysisByElevation(File currentDEM,double referenceElevation,int interpolation) throws Exception{// 讀取數據File currentDEMTfw = new File(currentDEM.toString().replace("tif", "tfw"));TfwInfo currentDEMInfo = new TfwReader().read(currentDEMTfw);DemData currentData = new DemReader().read(currentDEM);// 進行計算DigFillResultData result = computeByElevation( currentDEMInfo, currentData,referenceElevation, interpolation);return result;}private DigFillResultData computeByElevation(TfwInfo currentDEMInfo,DemData currentData,double referenceElevation,int interpolation) {double maxDigDeep = 0.0;double maxFillDeep = 0.0;double digVolume = 0.0;double fillVolume = 0.0;int width = currentData.getWidth();int height = currentData.getHeight();DigFillResultData result = new DigFillResultData();for (int i = 0; i < height - 1; i++) {for (int j = 0; j < width - 1; j++) {double currentXCoordinate = currentDEMInfo.getxCoordinate() + j * currentDEMInfo.getxStep();double currentYCoordinate = currentDEMInfo.getyCoordinate() + i * currentDEMInfo.getyStep();double interXStep = currentDEMInfo.getxStep() / interpolation;double interYStep = currentDEMInfo.getyStep() / interpolation;for (int x = 0; x < interpolation; x++) {for (int y = 0; y < interpolation; y++) {double currentXInterCoord = currentXCoordinate + x * interXStep;double currentYInterCoord = currentYCoordinate + y * interYStep;double currentValue = new ElevationInterpolation().caculateElevation(currentXInterCoord,currentYInterCoord, currentData, currentDEMInfo);if (currentValue != -32767.0) {double difference = currentValue - referenceElevation;if (difference > 0) {if (difference > maxDigDeep) {maxDigDeep = difference;}digVolume += difference * interXStep * Math.abs(interYStep);}if (difference < 0) {if (Math.abs(difference) > maxFillDeep) {maxFillDeep = Math.abs(difference);}fillVolume += Math.abs(difference) * interXStep * Math.abs(interYStep);}}}}}}result.setDigVolume(format(digVolume));result.setFillVolume(format(fillVolume));result.setMaxDigDeep(format(maxDigDeep));result.setMaxFillDeep(format(maxFillDeep));return result;}?
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的DEM挖填方分析--基于水平参考面计算的全部內容,希望文章能夠幫你解決所遇到的問題。