I'm working with qgis 1.8.0. I divided a map into 500 features (small rectangles), and now I have the doubt if there is any way to change the ID of the attributes from numbers to letters? When I did the division of the original map, each of the 500 divisions got one numeric ID (please refer to column 3 of image) and now I'm trying to load that map to STATPLANET PLUS and when working with that program, the ID may not be numerical. Any ideas?

Regards!! actual attribute table image of attribute table with column 3 showing integer values. configuration settings used on field calculator

  • 3
    Why not just use the field calculator to convert CVE_ENT to character type? You can even make it overtly alphanumeric by, say, prepending some common prefix to it, such as converting 28 to "ID28", etc. That should satisfy any software that insists the key be alphanumeric.
    – whuber
    Jul 25, 2013 at 21:37
  • @whuber, I tried to do the conversions with the field calculator, with the "tostring" tool under the conversions menu. What I did saw like this: tostring("ID"), then another column was created but was a numeric one, with the same values of the ID column, any conversion was done. I attached a picture of the settings I used on the field calculator, would you have an idea why is that happening?!
    – user20159
    Jul 26, 2013 at 12:32
  • 1
    From the left-justification of the entries in the [Name] field in your illustration, I infer that the operation completed correctly and that all ids were indeed converted to text exactly as you had requested.
    – whuber
    Jul 26, 2013 at 13:12
  • 1
    @user20159, in Expression window I try write "ID" (or tostring("ID")) - I receive attributes from numerical field in new text field. Try as write /whuber/ write in Expression window 'ID' || "ID" for result "ID28", etc. Jul 26, 2013 at 13:15
  • 1
    In the Field Calculator dialog, look within the string functions for a concatenation operator.
    – whuber
    Jul 26, 2013 at 15:14

1 Answer 1


My approach to this, which may not be the simplest, will still get you where you need to be. If you absolutely need to have letters for unique identified, I would create a CSV with two columns: ID and LetterID. ID will be numbers 1-500 and LetterID will be a two character string. There are 676 possible letter combinations with two characters and 26 letters of the alphabet.

To create the list of letters, write a simple python script with embedded for loops. This is a quick, lazy one I just wrote:

first = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
second = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

f = open ('UniqueLetter.txt', 'w')

for a in first:
    for b in second:
        f.write(a+b+ '\n')


Copy the values of your text doc into excel, crop to 500 values and add your join field (1-500). Save as CSV, import to QGIS, join to your shapefile and save or use field calculator to copy the unique letter combinations into a new field.

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.