[Gdal-dev] Joining DBF to SHAPE: Unrecognised primary field

Markus Neteler neteler at itc.it
Thu Nov 9 08:30:45 EST 2006


Hi,

I received the CORINE landcover map and want to join text attributes
from a DBF table to the landcover codes in the SHAPE file. Something
goes wrong, however:

# Figure out the column names:
ogrinfo -so 100kmE44N25.shp 100kmE44N25
...
 PROJCS["ETRS_1989_LAEA",
...
 CODE_00: String (3.0)
 AREA_HA: Real (17.5)
 SHAPE_area: Real (19.11)
 SHAPE_len: Real (19.11)

# Check table clc2000legendEEA15355I.DBF
ogrinfo -so clc2000legendEEA15355I.DBF clc2000legendEEA15355I
...
 Layer name: clc2000legendEEA15355I
 Geometry: None
...
 GRID_CODE: String (254.0)
 LEVEL1: String (254.0)
 LEVEL2: String (254.0)
 LEVEL3: String (254.0)
 CLC_CODE: String (254.0)
 LABEL1: String (254.0)
 LABEL2: String (254.0)
 LABEL3: String (254.0)
 RGB: String (254.0)

# The "join" columns are CLC_CODE in both files.

# doing it:
ogr2ogr -sql "SELECT 100kmE44N25.*,clc2000leg.LABEL2 FROM 100kmE44N25 LEFT JOIN \
        '/tmp/clc2000leg.dbf'.clc2000leg ON \
        100kmE44N25.CLC_CODE = clc2000leg.CLC_CODE" \
        100kmE44N25_leg.shp 100kmE44N25.shp

Is the string type a problem? If so, how to work around that?

Thanks
Markus



More information about the Gdal-dev mailing list