【问题标题】:ogr2ogr shp import to postgis and add columnogr2ogr shp 导入到 postgis 并添加列
【发布时间】:2021-07-08 12:36:51
【问题描述】:

我正在尝试将 shapefile 导入到不存在的 Postgis 表中。 我正在使用带有 -sql 选项的 ogr2ogr 从 shp 中选择要导入的字段,但是我需要在输出表中创建一个日期字段(在我的输入 shp 中不存在)。 ogr2ogr 中是否有任何选项?

我试过了:

ogr2ogr -f "PostgreSQL" -a_srs "EPSG:4326" PG:"host=<db_host> user=<db_user> password=<db_password> dbname=<db_name>" -nlt MULTIPOLYGON -nln <table_name> -sql "SELECT <shp_field1> AS <pg_field1>,  <shp_field2> AS <pg_field2>,  current_date AS date FROM <shapeFile>" -overwrite <shapeFile>.shp

但是,我收到一个错误“无法识别的字段名称 current_date”,这显然在我的输入 shapefile 中不存在。 感谢您的帮助。

【问题讨论】:

    标签: gdal ogr


    【解决方案1】:

    好的,我可以通过命令行添加 -dialect SQLite 来让它工作,但是它不再导入几何图形了...

    【讨论】:

    • 好的,只需将geometry AS geom 添加到上面的-sql 命令中
    猜你喜欢
    • 2017-12-18
    • 2022-10-13
    • 2010-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-03
    • 2014-09-18
    • 2017-05-14
    相关资源
    最近更新 更多