On mercredi 8 mars 2017 06:09:44 CET Mike wrote: > I'm getting this > Warning 1: layer names ignored in combination with -sql. > > However, I need to use the -sql query as I'm adding fields and populating > them as I go. > > The source dataset cannot be edited. > > I'm trying to combine several datasets into various tables in PostGIS, > where there's a name difference between the source layer and the PostGIS > table name. > > my command is in this format. > ogr2ogr -f PostgreSQL -a_srs "EPSG:4326" PG:dbname=SomeDB <insert some > options> Sourcedata -nlt POLYGON -skipfailures -explodecollections -sql > "SELECT *,'VALUE1' AS valuefield, 1 as anotherfield FROM <layer> WHERE > OGR_GEOMETRY='POLYGON' OR OGR_GEOMETRY='MULTIPOLYGON'" <layer> >
The issue is that you are using both -sql " " and layer_name, which are indeed exclusive. Either you import from a SQL statement or you import from a source layer_name. If you specify -sql "SELECT ... FROM layer_name", you don't need to specify it as a source layer_name. To do what you want, use -sql "SELECT ... from <layer>" -nln <layer>_suffix (note the -nln switch) > I wish to not put it in a table named <layer> in my PostGIS/SomeDB, but > rather <layer>+somesuffix > > This is easy with -nln, but when I added the -sql, I get the warning above, > and it seems to drop it in just <layer> and not <layer>+somesuffix. > > How can I accomplish what I want? > This is ultimately run on many datasets, so it will be appending to > existing tables (or create them if they didnt exist yet). > > -Mike -- Spatialys - Geospatial professional services http://www.spatialys.com
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev