地物分类预测
- 参考
- 源码notebook,https://github.com/databooks/databook/gis/iobjects10
- iObjects 10使用,使用SuperMap iObjects for python 10.0
# !/usr/bin/env python3
# coding=utf-8
import os
import time
from iobjectspy.ml.vision import Inference
Using TensorFlow backend.
设置输入数据路径
curr_dir = ''
data_dir = os.path.join(curr_dir, '..','..','example_data/')
inference_dir = os.path.join(data_dir, 'inference')
设置输出数据路径
out_dir = os.path.join(curr_dir, '..','..','out')
if not os.path.exists(out_dir):
os.makedirs(out_dir)
设置模型路径
model_path = os.path.join(curr_dir, '..','..','model')
land_cls_model = os.path.join(model_path, 'mul_cls_landcover', 'mul_cls_landcover.sdm')
数据模型预测
dom_path = os.path.join(data_dir, 'inference', 'landcover_infer.tif')
out_data = os.path.join(out_dir, 'out_land_classification.udb')
out_dataset_name = 'predict_land_cls'
start_time = time.time()
result = Inference(input_data=dom_path,
model_path=land_cls_model,
out_data=out_data,
out_dataset_name=out_dataset_name).multi_classify_infer(offset=200, result_type='grid')
end_time = time.time()
print('提取完成,共耗时{}s,结果数据保存在 {} 数据源下 {} 数据集中'.format(
end_time - start_time, out_data, result))
/home/data/hou/workspaces/iobjectspy/venv/lib/python3.6/site-packages/rasterio/__init__.py:216: NotGeoreferencedWarning: Dataset has no geotransform set. The identity matrix may be returned.
s = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
没有DSM数据,只使用DOM预测
/home/data/hou/workspaces/iobjectspy/venv/lib/python3.6/site-packages/rasterio/__init__.py:226: NotGeoreferencedWarning: The given matrix is equal to Affine.identity or its flipped counterpart. GDAL may ignore this matrix and save no geotransform without raising an error. This behavior is somewhat driver-specific.
**kwargs)
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]100%,16java -cp /home/data/hou/workspaces/iobjectspy/venv/lib/python3.6/site-packages/iobjectspy-10.0.0-py3.6.egg/iobjectspy/_jsuperpy/jars/iobjects-py4j.jar com.supermap.jsuperpy.ApplicationExample 127.0.0.1 41021
[iObjectsPy]: Connection gateway-service successful, Python callback port bind 36399
The multi classification have done!
提取完成,共耗时20.587729454040527s,结果数据保存在 ../../out/out_land_classification.udb 数据源下 predict_land_cls 数据集中
来源:oschina
链接:https://my.oschina.net/u/2306127/blog/3198273