[postgis-users] OGR2OGR to import non-spatial data

Paragon Corporation lr at pcorp.us
Mon Feb 18 17:41:34 PST 2008


This may be better posting to the GDAL list, but its related to Postgis sort
of, so thought we'd give it a try here first.

First of all we know OGR2OGR is designed for loading spatial data, but as a
side-effect seems to work fine for loading non-spatial data as well, and we
were hoping to use it as a light-weight data loader for our PostgreSQL
databases e..g copying data from MySQL to PostgreSQL and from SQL Server to
PostgreSQL, Access to PostgreSQL etc.

For our needs it works except for one tiny problem.  It always seems to
create geometry fields even if its a regular old table.

Example below

ogr2ogr -overwrite -update -f "PostgreSQL" PG:"host=pghost user=pguser
dbname=pgdb password=pgpassword"
MYSQL:"mydb,host=myhost,user=myuser,password=mypassword,port=3306" -lco
OVERWRITE=yes -lco SCHEMA=mysqldump -nlt NONE


This works great and copies over all the tables in the mysql database called
mydb into a pg database called pgdb and into a schema mysqldump, except the
datatypes are wrong (not too big of a deal for what we plan to use it for),
and it adds in blank wkb_geometry and ogc_fid fields.

If we have the tables created before hand - truncate all the tables and
reload (with append), everything works well, but for the first load its a
bit annoying.

Is there a way to prevent those wkb_geometry and ogc_fid fields from being
created.  We thought the -nlt NONE should do it, but doesn't seem to work.

Thanks,
Leo and Regina






More information about the postgis-users mailing list