IDL8.5进行影像裁剪代码

来源:互联网 发布:斯利曼尼俱乐部数据 编辑:程序博客网 时间:2024/05/29 11:49

IDL8.5对影像进行裁剪代码如下:

IDL中英文分号是注释符号

;这个函数完成影像裁剪工作;imgPath表示影像所在路径;outPutPath表示裁剪后影像的输出路径;upperLeftLat表示裁剪后影像左上角纬度;upperLeftLon表示裁剪后影像左上角经度;lowerRightLat表示裁剪后影像右下角纬度;lowerRightLon表示裁剪后影像右下角经度;本函数中的坐标为经纬度坐标,若为其他坐标系,适用性未知Function Subset,imgPath,outPutPath,upperLeftLat,upperLeftLon, lowerRightLat ,lowerRightLon    if File_test(outPutPath) eq 1 then Begin        return, outPutPath    endif    COMPILE_OPT idl2    e = ENVI(/HEADLESS)    path = string(imgPath)    raster = e.OpenRaster(path)    SpaRef = raster.SPATIALREF    SpaRef.ConvertLonLatToMap, UpperLeftLon, UpperLeftLat, ULMapX, ULMapY    SpaRef.ConvertLonLatToMap, LowerRightLon, LowerRightLat, LRMapX, LRMapY    SubsetRegion = ENVISubsetRaster(raster,SPATIALREF = SpaRef,SUB_RECT=[ULMapX, LRMapY, LRMapX, ULMapY])    e.ExportRaster,SubsetRegion, outPutPath,'tiff'    print,"裁剪成功"END;在这个过程中调用影像裁剪函数PRO layerstack  imgPath = "I:\LandslideResource\HJ数据\2011年\HJ1A-CCD2-15-84-20110313-L20000499902\499902\"  imgPath = imgPath+"波段合成.tiff"  outPutPath = imgPath+"波段合成_裁剪.tiff"  UpperLeftLat = 27.16756  UpperLeftLon = 103.22973  LowerRightLat = 26.90028  LowerRightLon = 103.535958  Result = Subset(imgPath ,outputPath,upperLeftLat,upperLeftLon, lowerRightLat ,lowerRightLon);END

以上代码在IDL8.5中测试通过,希望能帮助到大家

原创粉丝点击