码迷,mamicode.com
首页 > 其他好文 > 详细

将数据导入PostGIS

时间:2016-08-07 12:31:02      阅读:275      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!