5

New user. This should be simple, but I can't figure out how to perform this basic join in QGIS. (It works in Cartographica.)

My shapefile (IL_BNDY_County_Py) has two fields/columns in its attribute table: COUNTY_NAM and CO_FIPS.

My source DBF file (IL_BNDY_County_Py-species-dbf4.dbf) has three fields/columns: COUNTY_NAM, CO_FIPS and SPECIES. (The file is a literal clone of the shapefile table, with the addition of "SPECIES".)

Both are available as layers in my project.

I want to add the SPECIES field to the shapefile. Either COUNTY_NAM or CO_FIPS could serve as "key" field (to use terminology I'm familiar with from other software).

When I try to create a join, the Add vector join dialog shows the following options:

Join layer: IL_BNDY_County_Py-species-dbf4.dbf

Join field: (three menu options): COUNTY_NAM, CO_FIPS or SPECIES

Target field (two menu options): COUNTY_NAM or CO_FIPS

Is this what I should be seeing?

I can't figure out how to use this dialog to get the SPECIES field added to the shapefile. Part of the problem is that QGIS doesn't use the the term "key," so it's impossible for me to know which field QGIS wants to use to ensure the relationship. Given the options displayed, neither the "target" nor "join" field seems appropriate to serve as "key." How do I denote the "key" field?

If I choose SPECIES as the Join field, and CO_FIPS as the Target field, the results are duplicate columns for COUNTY_NAM and CO_FIPS with random mix of integer values and NULL values. SPECIES values are ignored and not copied over. I even tried creating a placeholder "species" column in the shapefile attribute table but still couldn't figure out how to get SPECIES copied over to species. What is the proper procedure for doing this? Is there another problem that I should be considering?

4

Select CO_FIPS as join and target field. That should do the trick.

The dialog basically just asks you which field in the first table should equal which field in the second table.

  • Thanks. That worked, but it also added a duplicate COUNTY_NAM field to the target table. Why? Is that normal behavior for QGIS? Seems wrong. – syncrasy Mar 3 '13 at 17:25
  • It's normal, all fields are copied over to the first table. – underdark Mar 3 '13 at 17:27
  • Ahh, of course. My mental map was wrong. Thank you. – syncrasy Mar 3 '13 at 17:31
  • Upvoted and accepted. (I wasn't able to upvote earlier. Apparently one must have a reputation to upvote, and I didn't have a reputation.) – syncrasy Mar 3 '13 at 19:11
  • Regarding the duplicate columns/fields again... How do I delete the duplicate columns? I tried to delete them but got a warning that the attribute could not be deleted. (And deleting the original column appears to delete both the original and the duplicate after the project has been saved, removing the join.) – syncrasy Mar 5 '13 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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