1

I am doing an ogr2ogr process where i will be making a join between two tables, imported as shapefiles and .csv to join on a column with idential attributes.

The code i've made so far looks like this:

    ogr2ogr -sql SELECT spmgnt100all_netto_rumnr.*, Areas_editeret.csv FROM spmgntall_netto_rumnr.* LEFT JOIN Areas_editeret.csv ON spmgnt100all_netto_rumnr.RUMNR = spmgnt100all_netto_rumnr.RUMNR Areas_Joined.shp spgmgnt_Joined.shp

But I am getting an error: "Error 1: Failed to create directory spgmnt100all_netto_rumnr., for shapefile datastore" ESRI Shapefile driver failed to create spgmnt100all_netto_rumnr.,

I suppose the error occurs when the .shp-table is submitted into another format and that is where the driver fails? Or maybe it means that ogr2ogr tries to make a shapefile that is the result of the process. And which fails.

But i might also understand the syntax wrong. I've tried to read my way through http://www.gdal.org/ogr_sql.html

0

1 Answer 1

2

FROM should contain table names, not column names (and 100 is missing here in the table name)

The ON part should connect columns from both tables, but you have specified the same table on both sides.

I suggest to put the whole sql statement in quotation marks, single ones for Linux and double for Windows.

The roles of dst_datasource_name and src_datasource_name are not clear to me. Where does the .csv file appear?

It might help if you add the table structures, or give a link to the files.

2
  • I'd made some changes to the Query. ogr2ogr -sql "SELECT spmgnt100all_netto_rumnr.*, Areas_editeret.* FROM spmgnt100all_netto_rumnr LEFT JOIN Areas_editeret.Rumnummer ON spmgnt100all_netto_rumnr.RUMNR = Areas_editeret.ADDED_Column" spmgnt100all_netto_rumnr.* Areas_editeret.csv Now it outputs that it has trouble making the .prj-file.
    – MichaelR
    Jun 25, 2016 at 20:55
  • What should be the dst_datasource_name? For src_datasource_name, you should specify the .shp file, not .*.
    – AndreJ
    Jun 26, 2016 at 5:36

Your Answer

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

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