Python@SuperMap shapefile 导入到超图文件数据集(udb)
webgis 2020-02-02
python
超图
# 开发环境
conda:4.8.2 #通过 anaconda 安装 后自带
python:3.6
平台:winsows 10
1
2
3
2
3
# 依赖环境配置
直接下载超图发布的,配置好的环境
miniconda 链接:https://pan.baidu.com/s/1T9dZjG_J3NXu45Sf6y-NHw 密码:nfei
java 环境 链接:https://pan.baidu.com/s/1lJkvo3yLNMbu3Zdy-YcggQ 提取码:l3ob环境配置
- 解压 miniconda
- 解压 java 环境包,然后配置 Bin 文件夹路径到 path 环境变量下
代码如下
# -*- coding: utf-8 -*- # @Time : 2020/3/17 23:59 # @Author : seelingzheng # @公众号 : seeling_gis # @File : importshp.py # @Software: PyCharm1
2
3
4
5
6from iobjectspy.conversion import import_shape import os,sys from os import path
shp_dir = r'F:\gisdata\实验数据\丰台gdb\output\样例'
udb_dir = r'F:\gisdata\实验数据\丰台gdb\test.UDB'
def loop_file(file): files = os.listdir(file) for f in files: new_file = file + os.sep + f print (new_file) if path.isdir(new_file): loop_file(new_file) elif path.split(new_file)[1][-3:] == 'shp': print(new_file+'*'*4) shp_udb(new_file)
def shp_udb(f): result = import_shape(f,udb_dir) print_info(result) def print_info(result): if result is not None: for item in result: name = item if not isinstance(item, str): name = item.name sys.stdout.write('导入数据成功,导入到数据集 %s\n'% name) if __name__ == '__main__': loop_file(shp_dir)1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
---
# 环境配置中可能出现的问题
1. 报 numpy 版本问题,可以卸载原来的重新安装如下版本,这个版本号是超图技术客服给的
```python
# 卸载 numpy
pip uninstall numpy imgaug
# 重新安装
pip install numpy == 1.15.0
pip install opencv-python==3.1.0.5
pip install imgaug==0.2.6
pip install opencv-python-headless
```
2. pip 镜像环境配置
```python
#windows 下
%HOMEPATH%\pip\pip.ini #如果没有可以手动创建
#在pip.ini文件中添加
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
# 也可以直接在 使用pip的时候在后面加入 镜像参数
pip install packagename -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25