#!/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

相关文章:

  • 2022-12-23
  • 2021-05-23
  • 2021-07-11
  • 2021-11-07
  • 2022-12-23
  • 2021-12-18
  • 2021-11-22
  • 2021-04-20
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2021-08-18
  • 2022-12-23
  • 2021-04-22
  • 2021-08-04
  • 2021-10-09
相关资源
相似解决方案