用冒号查询属性:在ogr2ogr和PostGIS之间

时间:2019-06-05 06:17:38

标签: postgis gdal ogr2ogr osm2pgsql

我正在运行由osm2pgsql填充的PostGIS数据库。地址键例如存储为

"addr:street"

目标是通过ogr2ogr将这些几何存储为GeoPackage。脚本看起来像这样

ogr2ogr -f "GPKG" address_point.gpkg PG:"host=**** dbname=**** user=**** password=****" -sql "select addr:housenumber","addr:housename","addr:flats","addr:conscriptionnumber","addr:street","addr:place","addr:postcode","addr:city","addr:country","addr:full","addr:hamlet","addr:suburb","addr:subdistrict","addr:district","addr:province","addr:state","addr:interpolation","addr:interpolation","addr:inclusion","addr:door","addr:unit","addr:floor","addr:block",way from planet_osm_point"

ogr2ogr由于每个属性中的冒号而返回错误。 我认为,查询失败是因为“ wich假设要包装对ogr2ogr的查询。

当我使用'时,如下所示:

ogr2ogr -f "GPKG" address_point.gpkg PG:"host=**** dbname=**** user=**** password=****" -sql "select 'addr:housenumber','addr:housename','addr:flats','addr:conscriptionnumber','addr:street','addr:place','addr:postcode','addr:city','addr:country','addr:full','addr:hamlet','addr:suburb','addr:subdistrict','addr:district','addr:province','addr:state','addr:interpolation','addr:interpolation','addr:inclusion','addr:door','addr:unit','addr:floor','addr:block',way from planet_osm_point"

查询也失败。

有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:0)

您需要在字段名称周围使用双引号

ogr2ogr [...] -sql "select \"addr:housenumber\",\"addr:housename\" from planet_osm_point"

或者您可以对整个SQL字符串使用单引号

ogr2ogr [...] -sql 'select "addr:housenumber","addr:housename" from planet_osm_point'