I read in a CSV file for linking to a .shp file. All the variables that are just numbers came in as text. How do I change the text variables to numeric in QGIS?
I once had the same question. The answer is that you put a file in the same folder with the ending csvt. For example your file name is xyzdata.csv you add the file xyzdata.csvt
This one you can edit with editor for example. And in it you set the data type like this. "Integer","String","Integer","Integer","String","Real"
Integer is now the variable for the first column, string for the second and so on... Make sure the files are named identically.
Edit: See here too if needed: http://underdark.wordpress.com/2011/03/07/how-to-specify-data-types-of-csv-columns-for-use-in-qgis/
|show 2 more comments|
Rather than messing with the input file, trying to get everything picture perfect, just use the field calculator to convert the text to a number / real. See the examples below:
Another alternative in case of large datasets to be managed and obviously time consuming to to proceed with the field calculator (without looping) or within a text editor : - save your data as CSV + XY + variable for the joint with our polugone shapefile - upload your CSV with the plug in (import csv) then save as shapefile (point) - then close q gis - back to the folder with the shapefile point, duplicate the corresponding dbf table / rename - open Qgis - upload the new dbf and join to shapefile (polygone features)
One stone, two pigeons : you have potentally 1) a shapefile point with all the data and all the possibility of represention 2) and independant shapefile with dbf table joined (editable !) linked to polygone for thematic cartography
This is a bit rude , but quite straightforward ...