I noticed that after joining a table to a shape file the headers of each fields in the table used for the join are changed by QGIS and they are attributed to a different name. For instance, i had a shape file with vegetation_codes and a table with vegetation_codes and veg_definition (these were the headers). After joining the table to the shape file and also saving the shape file and creating a new one, the vegetation_classes header was changed into vegetati_1. Is there a way to keep the original headers? Notice: i am using QGIS dufour on windows 7 and teh table that i join to the shape file is csv (tried with dbf as well and the problem is the same)
No, you cannot keep the original names. The problem is that DBF files and therefore Shapefile attribute tables have a limit of 10 characters for the column names.
When you join two layers, QGIS constructs new attribute names by combining layer and attribute names of the joined layer. To ensure unique column names, QGIS further adds a running number to the end of the name.
You'll have to rename the columns in the resulting file manually. The Table Manager plugin allows easy renaming.
I had the same problem and figured out a solution with the 'processing modeler' from QGIS 2.6. Weird enough: in the resulting shapefile, the original columnnames from the .dbf are kept!
How to use the processing modeler?
With the processing modeler you can automate whatever geoprocessing, analysis, datamanagement, etc you do within the usual QGIS environment. In this case I want to join a table to a shapefile and save it as a new shapefile to get an extended attributetabel.
Within QGIS first I have to load a shapefile and the table I want to join with.Then I have to perform that join by entering the Layer Properties and define the joinspecifications under the tab join. Then I have rightclick the shapefile and choose 'save as', fill in a dialogue window and enter the specifications. Then I need to rename all the added fields because they are renamed to obtain unique fieldnames. A lot of work if you have to do a lot of them.
Within the processsing modeler you only have to add these steps once. After saving the model you can easely re-use it.
Enter the processing modeler through processing > graphical modeler
You get something like this
Activate the tab Input as shown above. Double click 'Vector layer', you get:
Fill in a descriptive name: eg. original shapefile.
Double click 'Table field', you get:
Fill in a descriptive name: eg. Field to join with. The parent Layer is automaticly set because you only have one input added.
Double click 'Table' and give it a descripive name: eg. table to be joined.
Double click 'Table field', fill in a descriptive name: eg. joinfield. Check if the parent Layer is set correctly to the name you gave to the table.
Untill now you only have defined the needed features: shapefile, table and their corresponding unique fields.
Now we have to define the algorithm. Open the 'Algorithms' tab.
Here you find all the scripts an algorithms that are used within the 'normal' QGIS-interface. To easely find the right algorithm, enter a description in the searchfield.
Double click on 'join attributes table'. You get a dialogue window where you have to define the right parameters as shown.
When you enter a name under 'output layer', you will be asked to add a name and location for the new shapefile that will be created.
Now you can see in the right panel the relations between the inputfields, the algorithm and the output.
Give your model a name and save it.
Now you can test the model by running it. Press .
Select the shapefile, table and corresponding fields.
Press 'Run' and see if everything goes fine. If not, you can change parameters in the processing modeler and try it again.
The nice thing about the models is that you can run them in batchmode. Open the toolbox !
Right click your model and choose
You can now run different joins at the same time.