使用ogr2​​ogr更新pgsql表,遇到PK问题

时间:2016-10-05 15:32:18

标签: postgresql postgis ogr2ogr

使用ogr2​​ogr导入新的GIS数据(从osm或特定),从shp到pgsql时,我遇到了问题。 要创建我的表,我使用:

function _classCallCheck(instance, Constructor) {...abridged...}

var Person = function Person() {
  _classCallCheck(this, Person);

  this.printA = function () {
    console.log('a');
  };
};

使用PGSQL_OGR_FID强制pgsql将我的原始列用作主键。这个密钥必须使我的更新成为可能。

因此,要使用新数据进行更新,我想这样做:

ogr2ogr -overwrite --config PGSQL_OGR_FID myid -gt 65536 -f "PostgreSQL" "PG:host='host' user='myself' dbname=db  password='motdepasse'" -nln rues --config GDAL_DATA "C:/OSGeo4W64/share/gdal" -t_srs EPSG:2154 "C:/test01.shp"

但是pgsql完全不喜欢它!我希望它用新的替换相同PK的数据,但它想保留旧数据并采用新的数据,这当然是不可能的,所以消息是:

ogr2ogr -update -append  --config PGSQL_OGR_FID myid -gt 65536 -f "PostgreSQL" "PG:host='host' user='myself' dbname=db  password='motdepasse' active_schema=public" -nln rues --config GDAL_DATA "C:/OSGeo4W64/share/gdal" -t_srs EPSG:2154 "C:/test02.shp"

是否可以使用ogr2​​ogr替换数据?在更新时,似乎想要保留所有内容...... 我不知道该怎么做......也许在我的请求中使用SQL查询......

奇怪的是,这似乎与sqlite / spatialite合作! (见http://lists.osgeo.org/pipermail/gdal-dev/2011-December/031099.html

非常感谢你有任何解决方案,对不起我的英语不好!

西里尔

0 个答案:

没有答案
相关问题