0

I'm trying to follow the accepted solution from this post: Join CSV file to shapefile using gdal/ogr

But I keep getting the error "no such table". My CSV does in fact exist. Can somebody diagnose this issue?

Here is my exact command:

ogr2ogr -nln tax_polys -sql "select tax_polys.*, veg_cover_table.* from tax_polys left join '/home/rstudio/repos/model-based-inf/data/tax_polygons/veg_cover_table.csv'.veg_cover_table on tax_polys.SWIS_SBL_ID = veg_cover_table.SWIS_SBL_ID" /home/rstudio/repos/model-based-inf/data/tax_polygons/tax_parcels_w_veg_cov.gpkg /tmp/Rtmpgys1cg/tax_parcel.gpkg

And here is the error:

ERROR 1: In ExecuteSQL(): sqlite3_prepare_v2(select tax_polys.*, veg_cover_table.* from tax_polys left join '/home/rstudio/repos/model-based-inf/data/tax_polygons/veg_cover_table.csv'.veg_cover_table on tax_polys.SWIS_SBL_ID = veg_cover_table.SWIS_SBL_ID):
  no such table: /home/rstudio/repos/model-based-inf/data/tax_polygons/veg_cover_table.csv.veg_cover_table
Vince
  • 20,017
  • 15
  • 45
  • 64
Lucas
  • 593
  • 4
  • 16
  • 1
    Your syntax will not work with GeoPackage. Read the SQLite SQL dialect documentation https://gdal.org/user/sql_sqlite_dialect.html. – user30184 Sep 23 '23 at 16:06

1 Answers1

1

As the comment from @user30184 pointed out. GeoPackage was not compatible with this syntax. By converting my input shape to a ESRI shapefile, this command worked.

Lucas
  • 593
  • 4
  • 16
  • Another option would have been to change your syntax. There is an example in the documentation ogrinfo jointest.gpkg -dialect INDIRECT_SQLITE -sql "SELECT a.ID,b.ID FROM jointest a JOIN \"jointest2.shp\".\"jointest2\" b ON a.ID=b.ID". – user30184 Sep 23 '23 at 17:11