[Gdal-dev] Re: Problem using OGR and join-functionality: column
names gone when creating a new shapefile?
Neil Best
nbest at speakeasy.net
Sat Sep 16 08:16:35 EDT 2006
Hi, Wolfgang. I think if you look at my recent posts to the list you
will see that we are experiencing similar difficulties, you and I. I
wanted to do the same thing, make a join permanent, the only difference
is that my source data is a .shp and a .dbf, rather than related tables
in an RDBMS.
Since I can't get it to work either I can't speak with much authority,
but I think I can point out something about your problem with field
names. If you look at the section describing joins on the OGR SQL page
you will see a detailed discussion of how column names in the SQL
statement map to the output. My guess is that OGR is trying to give you
fully qualified column names (e.g. "flurstck_test.ich_weiss_was_nicht")
and truncating them according to the .dbf conventions. Try using some
aliases in your SQL. If you post your query and a minimal description
of your columns to the list I can try to offer a suggestion.
What's interesting is that we are both running the same version under
Debian, albeit I am using Ubuntu. I don't know if this is significant
or not, especially since I got the same results when I dropped back to
1.2.6, but there it is . . .
Neil
wqual wrote:
> Hi list,
> yesterday, I found a very interesting page on the internet - manpage of OGR
> SQL [1]. Wow, I thought - I can perfom JOINs on the command line. Using
> the join-command as described in this manual combinded to the ogrinfo-command
> clearly showed, that a join was performed.
> *But could I make this permanent?*
> Within the next step, I used ogr2ogr with the same sql-expression. A new
> shapefile was created, the desired column of the second theme was appended to
> the table (ogr2ogr -f "ESRI Shapefile" testfile.shp ./ -sql "select ...."
>
> However, I realised, that all the column names were gone, or to be more
> precise, lost their names in favour of a new one. All column names of the
> first shapefile "Flurstck_test.shp" were (re)-named to "flurstck_t" and the
> new column of the second theme "flurstck_nr.shp" is named "flurstck_n" now.
> Also, the column definitions were all converted to "Real" except the column
> that was appended (joined) to the table. This column is of type "String".
>
> Is this a common (known problem)? I would be most grateful for some comments,
> as I really would like to use this feature of ogr! Thanks in advance!
>
> I am using gdal 1.3.2-2 on a Debian machine.
>
> Best regards,
> Wolfgang
>
> [1] www.remotesensing.org/gdal/ogr/ogr_sql.html
More information about the Gdal-dev
mailing list