Tuesday, 19 May 2015

qgis - How do "join field" and "target field" work?



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?



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...