15

I have a shapefile I made in QGIS 1.7.4. One of the fields is a String of length 80. I'd like to make the field accept longer stings, but I can't figure out how to change its length.

How do I do this?

6 Answers 6

17

Warning: first make a backup.This is an experiment though it worked for me just now..

open the .dbf of the particular shapefile using OpenOffice Calc application. Change value from 80 to whatever value you want. See the image below. Surprising thing is these field definitions were not visible in Excel.

enter image description here

0
17

To my knowledge, you cannot alter the length of shapefile fields in QGIS. Recommend creating a new field:

  • Open attribute table
  • Toggle editing on
  • Select 'New Column' and set
    type to text, and choose the desired width

If there is already data in the old field, use field calculator to populate the new field:

  • Select 'Field Calculator'
  • Tick 'Update existing field' and choose the new field
  • Double-click the old field name under 'Fields'
  • Hit 'OK' and don't forget to save your edits.
0
4

I've just done this in Excel. open the dbf in Excel, right click the column header you want to change and select Column Width. Change to the length you need, then save as a dbf. Seemed to work OK for me.

0
1

Guide to changing the column size for the Attribute table in QGIS

  1. Right click on the vector layer and select properties.
  2. Go to the field tab.
  3. Add a new column (This button is in the top right hand corner. a. Make sure to match all the data as the column you are, trying to widen. Except the length change that to your desired length.
  4. Select ‘Field Calculator’ button (This button is in the top right hand corner.)
  5. Check the ‘Update existing field’
  6. Make sure ‘Update selected field only’ is unchecked.
  7. Choose new field from the menu right next to the check boxes
  8. Under the Field Menu double click the old field
  9. Hit okay and save the edits
  10. *Go to Table Manager Plugin a. PlugingsTableTable Manager
  11. Select and delete old field
  12. Rename new field to old one.

*You will need to install Table Manager Plugin.

0

Scro's solution as more thoroughly explained by YP-kun just worked for me. One change now with QGIS 3.4, no need to use Table Manager for YP-kun's steps 10 and 11 (to delete the old column). In fact, Table Manager apparently is no more as it is now not available in Plugin Manager. Now, after YP-kun's steps 1-9, you can go to Layer Properties for the layer (double click on the layer in the Layer panel, or right click on it and click on Properties) > Source Fields > click the edit button > then select the old field you want to delete > click Delete Field button > then edit button again to close editing > save your changes. Seems like a lot to go through to change the length of a single field in a single layer, but so be it. We are lucky to have QGIS and thank you very much to those of you who develop it and its plugins.

-1

Search for the 'refactor fields' from the processing tools.

you can edit field length from there

2
  • This doesn't change the length in place, it will create a new layer and file that you have to deal with. :-(
    – Nick K9
    Commented Sep 24, 2023 at 16:53
  • Note: this method creates a new file/layer. If you have any styling on the current layer, the new later will lose that.
    – Nick K9
    Commented Sep 24, 2023 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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