[gdal-dev] ogr2ogr - exclude table option?

Even Rouault even.rouault at spatialys.com
Wed Nov 30 09:05:09 PST 2016


On mercredi 30 novembre 2016 16:21:42 CET Neumann, Andreas wrote:
> Hi,
> 
> I want to convert a whole Postgis schema to a geopackage. This works
> fine with
> 
> ogr2ogr -f GPKG av_1700.gpkg PG:'dbname=dbname host=localhost
> schemas=schemaname'
> 
> Now - my problem is that the schema contains 64 tables and I want to
> convert all tables except one table.
> 
> Is there a trick with an exclude option? I know that I can list all
> tables that I want to convert in the sense of a white list with
> 'tables=tab1,tab2,tab3', etc. - but this is complicated for this many
> tables.
> 
> I hope that there is / could be some black list option - or the
> possibility of specifying a pattern for selection the tables to be
> converted.

Andreas,

There's no such option (there's no real technical hurdle if one would want to add one, but 
one can wonder how common this use case is)
The easiest way currently would be to drop the unwished tables after the import : ogrinfo 
your.gpkg -sql "DROP TABLE table_name". Since GDAL 2.1.2, this not only drops the table but 
also all references to it in GPKG system tables.
You could also do a tiny script to list the tables and remove the one(s) you don't want from 
the list before calling ogr2ogr / gdal.VectorTranslate()

Even


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20161130/0bfd4df6/attachment.html>


More information about the gdal-dev mailing list