[Gdal-dev] ogr2ogr and field matching

Armin Burger armin.burger at gmx.net
Tue Aug 2 15:04:59 EDT 2005


Hello everybody,

I tried to use ogr2ogr for loading data from shapefiles into PostGIS 
because it gives more flexibility than the shp2pgsql utilitiy.  I tried 
to combine data from different sources that can have differences in the 
field names of the shapefiles. ogr2ogr offers the possibility to specify 
the SQL command for loading. So I tried

"ogr2ogr -sql "SELECT ARRGCDL0 AS iso
FROM countries WHERE ARCNTY_ID>100"  -a_srs "EPSG:4326" -append
 -f PostgreSQL PG:'host=localhost user=postgres dbname=testdb'   
countries.shp"

But I get the error
ERROR 1: SQL: Missing comma after column ARRGCDL0 in SELECT statement.

So there seems to be no possibility to map an existing column in the 
shapefile to an existing in the PG table using the 'AS' statement. When 
the two column names differ, the data from the shapefile field are just 
not loaded into the PG table. Are there any workarounds for that?

Thanks in advance for any help

Armin



More information about the Gdal-dev mailing list