1

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
1

1 Answer 1

2

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.

1
  • 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
    Commented Sep 23, 2023 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.