1

So I am trying to join some data I have (just numbers) to a map on QGIS.

However it when I try to join the data to map it shows up as a string instead of a real.

It's a just a normal exel file. I converted it to a CSV file and was able to join it to my map, however as a CSV file it was still a STRING so I couldn't use graduated symbols.

  • What's the source table format of the table you're joining? Is it a csv? – SaultDon May 17 '17 at 15:03
  • It's a just a normal exel file. I converted it to a CSV file and was able to join it to my map, however as a CSV file it was still a STRING so I couldn't use graduated symbols. – Mareykan May 17 '17 at 15:18
  • 1
    As a csv, you could create a csvt file that specifies the column type in the csv, then maybe qgis will have better luck with the join. – SaultDon May 17 '17 at 15:22
  • @SaultDon for the csvt file, what column type would I use? The data I want to add is only two columns, first is labeled GEOID, and the second is Percent Income. – Mareykan May 17 '17 at 15:27
1

If you're using a csv, then you can create a csvt file to go with it.

For example, if your csv is called file.csv then create a new text file called file.csvt

The csvt file only needs a single line with something like: "String","Real","String","String","Integer",...

Where each column is the type found in the original csv. They just need to be surrounded by double quotes and separated by a comma.

There's some additional info at http://www.gdal.org/drv_csv.html where it also mentions you can specify width and scale of the Integer or Real types like:

From the site,

"Integer(5)","Real(10.7)","String(15)"

or starting with gdal 2.0 or greater

"Integer(Boolean)","Integer(Int16)" and "Real(Float32)"

  • So I did that, and the map just basically became covered in red hashes – Mareykan May 17 '17 at 16:06
  • Not to sure, maybe at this point if it's possible - share the data you're working with. Would make troubleshooting a lot easier. Or update you're question with some details on what exactly you've tried, step by step and the result with maybe some screenshots. – SaultDon May 17 '17 at 16:09
  • .... it was in toggle mode :( but thanks that help – Mareykan May 17 '17 at 16:19
1

If you are importing data from a CSV file by 'Add Vector Layer' option then by default the interpreted column type is 'string'. Try adding the data using 'Add Delimited Text Layer' and choose no geometry option. It would guess the datatype.

Refer this link for details about this option.

You can also look the 8th step of this tutorial for help regarding your csvt file.

  • I've just been adding by dragging and dropping. The weird thing is the data set for just Brooklyn works fine to add, but the entire dataset (all 5 boughs) doesn't work. – Mareykan May 17 '17 at 15:32
  • Did you try to add the data using the Add Delimited text Layer option? It usually works for me and recognizes the datatypes automatically. – nash May 17 '17 at 16:14

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