2

So I am having a shapefile with all the world countries. And the table for this shapefile has a column named "Country Name". Each of this entry is unique, meaning, each country takes only 1 row, and each with it's own polygon represented in the shapefile and ID.

Now I have a .csv file with all the countries again. Now this .csv file has the column "Country Name" too, but this column has several rows containing the same country name, because, it also has a column called "Year", therefore each country has several row entries for each year.

How can I join my shapefile table with this .csv table? Right now, my problem is that when joining, only the first entry from the .csv file is being joined, since the shapefile table only has 1 row per each country entry.

Any suggestions how I can a union join, meaning that each country in my shapefile will be assigned every year found in the .csv file? I think it means that each polygon needs to be multiplied for every year entry from the .csv file.

Thanks

EDIT: According to ArcGIS Resources - joining and relating tables, "In all cases of 1:M joins, only the first matching record is joined and displayed in the layer's attribute table.". Which is actually the problem I have. Only the first matching record is displayed in my shapefile table.

So I believe I now need a work around? Since my .csv is having my data by year, but each year is a row (and the same country is spanning several rows for each year row), would I need to create a column for each of the years, and somehow transfer the data found in each row from my .csv file to the columns of my shapefile?

4 Answers 4

1

Relates work with a 1:M relationship between two tables. Right-click the layer to define the Relate. After defining the Relate, the Identify Tool will list the related records also.

0

send your csv to a geodatabase, create a new field called "country2" or something along these lines, right click this field, make sure it's a string. Visit your field calculator in the attribute table. Country2 should = Country Name. This should be a string.

So, In your field calculator you should have something that looks like

Country2 = County Name and click ok.

Retry your join.

0

Here is the beginning of the Join toolset in toolbox explanation.
For more information on one-to-one, many-to-one, one-to-many, and many-to-many joins, see About joining and relating tables
You can accomplish a 1:M join by using a geodatabase.
(limitation on shape, dbf and csv joins)
Simply load your data to a file gdb and use it in a join from there.

1
  • I found this caution: "In all cases of 1:M joins, only the first matching record is joined and displayed in the layer's attribute table." Also, thinking about it, in my shapefile, each country is unique, has a unique "FID". When I do a 1:M join, I don't think it's possible to create more rows for each country in my shapefile because the FID would be violated, FID would no longer be unique. That is the problem I am having. I can only see the first matching record.
    – Iuli
    Oct 29, 2013 at 20:47
0

Please check out the following link

http://www.digital-geography.com/qgis-tutorial-ii-how-to-join-data-with-shapefiles/

will be helpful for you.

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.