Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have county data in which the FIPs (actually State FIPS and County FIPS combined). I have data imported as CSV with the sames FIPS data titled STCounty. However, the shapefile FIPS is listed as a Real and the CSV came in as an Integer and the Join function does not seem to work. The drop boxes are greyed out/empty.

So the bigger questions is how do you change the attribute type in a table? I tried to create a new column in the shapefile (county data) and set it to an integer and then multiply the FIPS*1, but got a column full of "NULL".

I am new to QGIS and have a lot of experience in MapInfo, so the join concept is not new to me, just the syntax in QGIS.

share|improve this question

Creating a new integer column is the right way to go - but the 1*FIPS that you used (which would work in Excel or Libreoffice) is where the problem comes in; QGIS doesn't automatically convert between field types in a calculation.

You need to use one of the conversion functions (toint converts to integer, tostring to text, and toreal to real/decimal) with the correct column name:

toreal("FIPS")

You can use the Tablemanager plugin to then remove unnecessary columns.

Setting up a .csvt file would be the best repeatable solution but for a single column, this should be pretty straightforward.

share|improve this answer
    
The 1*FIPS also works in ArcGIS. – L_Holcombe Nov 5 '12 at 20:28
    
seems kind of silly not to be able to just change the datatype. However, this does seem to be the correct answer – chrismarx Mar 28 '14 at 19:15

I once answered this question;If you import your Data from a csv file you need to create a csvt file in order to determine the attribut type of a field. See the explanation here: How to change an attribute value from text to number?

Jo

share|improve this answer

I just had the same problem. In my case i work with Libreoffice and QGIS.

I exported a table from R to .CSV with two columns: "id" and "veh". "id" is Integer and "veh" Real.

write.csv(tab2,file='/path/table.csv',row.names = F)

When i open the table.csv in Libreoffice the field veh was read it as "string". So i created another coulmn "vehh" as the multiplication of "veh"*1, and the result was the desired number . Then i saved the file as .ODS (Libre Office)

Then i load the table.ODS in qgis and "vehh" was recognized as Real.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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