1

In QGIS 2.18.9...

I have a shapefile with two attributes 'ID' and 'POP', each of which is of the integer type.

I have a CSV file loaded as a delimited, text-only table layer with two attributes 'ID' and 'EMP', each of which is of the integer type.

I use the standard QGIS algorithm 'Join attributes table' to join the table to the shapefile based on the common attribute 'ID'.

The join executes as desired, except that:

1) I can only get an output shapefile if I choose to create a temporary output layer instead of specifying a file name and location for it to save to

2) in this temporary output shapefile, the two attributes from the original shapefile are now of the text/string type instead of the integer type even though the two attributes from the joined table are still of the integer type

1

In order to join the data with the same data type, you need to create a CSVT file with the same CSV filename where you indicate the column data type inside then place the csvt in the same directory.

Example:
my_data.csv
1,"voldemore,100

my_data.csvt
"Integer", "String", "Integer"

Reference:
http://www.qgistutorials.com/en/docs/performing_table_joins.html

  • Yes, I did write a CSVT file and store it in the same folder as the CSV file. The CSV file loads correctly - i.e. with the correct data types.The issue is that the type of the attributes 'ID' and 'POP' in the original shape file changes from 'integer' before the join algorithm to 'string' after the join. – james Feb 14 '18 at 14:26

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.