首页 > 其他 > 详细

将数据导入PostGIS

时间:2016-08-07 12:29:21      阅读:250      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import subprocess

# database options
db_schema = "SCHEMA=geodata"
overwrite_option = "OVERWRITE=YES"
geom_type = "MULTILINESTRING"
output_format = "PostgreSQL"

# database connection string
db_connection = """PG:host=localhost port=5432
    user=pluto dbname=py_geoan_cb password=stars"""

# input shapefile
input_shp = "../geodata/bikeways.shp"

# call ogr2ogr from python
subprocess.call(["ogr2ogr","-lco", db_schema, "-lco", overwrite_option,
    "-nlt", geom_type, "-f", output_format, db_connection,  input_shp])
    
# -lco is the layer creation option
# -f is output format
# -nlt new layer type

将数据导入PostGIS

原文:http://www.cnblogs.com/gispathfinder/p/5745793.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!