如何利用 GDAL-Python裁剪栅格数据(DEM等)2019

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/hengcall/article/details/90737034

ARCGIS裁剪数据量比较大的栅格很容易卡死,故用gdal。

可批量裁剪多个shp的组合。

翻阅了一些博客,这么一个简单的功能写得很复杂。提供代码供有需要的各位参考。

from osgeo import gdal

input_raster = r"F:\JUNK\dem90.tif"
# or as an alternative if the input is already a gdal raster object you can use that gdal object
input_raster=gdal.Open(input_raster)
input_shape = r"F:\JUNK\gla-shp.shp" # or any other format
output_raster=r'F:\JUNK\test2.tif'   #your output raster file

ds = gdal.Warp(output_raster,
              input_raster,
              format = 'GTiff',
              cutlineDSName = input_shape,      # or any other file format
              cutlineWhere="FIELD = 'whatever'",# optionally you can filter your cutline (shapefile) based on attribute values
              dstNodata = -9999)              # select the no data value you like
ds=None     #do other stuff with ds object, it is your cropped dataset. in this case we only close the dataset.

 

展开阅读全文

DEM 的数据结构 USGS DEM

04-16

BLAKESBURG, IA-24000 LAT:: 40 52 30.0000 N LONG:: -92 37 30.0000 W SCALE:: 24000 (SDTS2DEM v.0.018) 1 1 1 15 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 0.000000000000000D+000 2 2 4 5.210656985000000D+005 4.524699405894000D+006 5.210260270650000D+005 4.538575238674000D+006 5.315390237710000D+005 4.538612856832000D+006 5.315985314340000D+005 4.524737000352000D+006 2.240000000000000D+002 2.970000000000000D+002 0.000000000000000D+000 03.00000e+0013.00000e+0011.00000e+000 1 352 2 1 1 1 163 1 5.210400000000000D+005 4.533690000000000D+006 0.000000000000000D+000 2.540000000000000D+002 2.910000000000000D+002 267 263 261 262 262 263 264 265 268 270 272 273 273 275 278 282 284 286 286 284 284 286 287 289 289 289 289 288 289 290 290 290 289 287 282 278 276 275 274 270 272 278 283 284 281 276 274 275 280 285 289 290 289 287 286 286 287 288 288 286 285 286 287 286 285 285 285 283 281 277 273 268 263 257 254 254 254 254 254 256 257 258 259 260 261 262 262 263 265 269 271 273 275 278 282 285 287 287 286 286 286 285 285 285 286 286 286 287 289 290 289 288 289 290 288 286 284 286 287 286 286 288 289 290 291 291 291 291 291 290 289 288 288 287 286 286 286 284 283 285 286 286 285 285 286 288 289 289 288 285 282 277 276 281 284 283 282 284 286 288 289 289 289 rn .........................rn 这是一个*.dem文件的文件头,请问哪位高手知道这个文件每个数据的含义。感激涕零!!! 论坛

没有更多推荐了,返回首页