from iobjectspy import (clip_raster, Rectangle) import os import sys
# 設置示例數據路徑 example_data_dir = '/home/jovyan/data/smdata/' # 設置結果輸出路徑 out_dir = os.path.join(example_data_dir, 'out')
if not os.path.exists(out_dir): os.makedirs(out_dir) def progress_func(step_event): sys.stdout.write('%s,%s %d %%\n' % (step_event.title, step_event.message, step_event.percent)) def clip_image_test(): """裁剪影像數據集""" clip_region = Rectangle(875.5, 861.2, 1172.6, 520.9) result = clip_raster(os.path.join(example_data_dir, 'example_data.udb/seaport'), clip_region, True, False, out_data=os.path.join(out_dir, 'out_clip_raster.tif'), progress=progress_func) if result is not None: print('裁剪影像數據成功,結果存儲在 ' + result) else: print('裁剪影像數據失敗')
if __name__ == '__main__': # 裁剪影像數據 clip_image_test()
java -cp /opt/conda/lib/python3.6/site-packages/iobjectspy/_jsuperpy/jars/com.supermap.jsuperpy-9.1.1.jar com.supermap.jsuperpy.ApplicationExample 127.0.0.1 40153 [iObjectsPy]: Connection gateway-service successful, Python callback port bind 44913 裁剪影像數據成功,結果存儲在 /home/jovyan/data/smdata/out/out_clip_raster.tif