Hi, I would suggest to consider other options first.
* Use OGR foreign data wrapper https://github.com/pramsey/pgsql-ogr-fdw and make the shapefile to appear as a PostGIS table. The you can make the JOIN in your PostGIS. * Add both the shapefile and the classification table from PostgreSQL into GeoPackage or SpatiaLite database as separate tables and update the coded values into definition string with SQL locally. If you really want to join shapefile and PostgreSQL tables directly with GDAL and ogr2ogr I believe the only way is to write a vector VRT file https://gdal.org/drivers/vector/vrt.html#vector-vrt that makes those two to appear as two layers in one datasource. The result is actually logically rather similar than by using foreign data wrappers on the PostgreSQL side. If I would need to do the task just once I would take the GeoPackage road but I have done that before and my view is therefore certainly biased. -Jukka Rahkonen- Lähettäjä: gdal-dev <gdal-dev-boun...@lists.osgeo.org> Puolesta Andrés Nadal Lähetetty: torstai 18. marraskuuta 2021 16.50 Vastaanottaja: gdal-dev@lists.osgeo.org Aihe: [gdal-dev] ogr2ogr, perform queries to obtain values from the database Hello. Excuse me my English, it's not my native language. I need to convert the names (string) of classes, in some fields of a Shapefile, to the respective numerical values of the database. In some cases, the fields have up to 3 different classes, for different rows. CLASS A = 1 CLASS B = 2 CLASS B = 3 The destination table, this already exists, and contains many other fields, this using ogr2ogr.exe, from Windows CMD. How to indicate to ogr2ogr.exe, which performs a query first, to obtain the numerical value of the ' CLASS B', from PostGIS. In this way insert the value 2 in the table. Thank you
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev