I want to add several new columns to a shapefile (v.db.addcolumn), using GRASS GIS 7.0.5, but the software don't allow me to change the "length" (set to 250), and it provides and error when asking to add the column ("Error: Unable to add column <1 integer>.; where "1" is the name of the column and "integer" is the type).

It already worked in other shapefiles, with the same version. I tried to create a new project, work with another shapefile but it does not seem to work anymore.

Does anyone know what may be the problem, and how to solve it?


If you are working with a GRASS vector, then it's not a shapefile, rather the internal vector data structure. And GRASS map names cannot start with a number (due to SQL limitation). Try:

v.db.addcolumn <vector name> column="col_1 integer"

If you have a shapefile created in some other GIS software which allows column name starting with a digit, and you import into GRASS, those columns will get renamed.

Even ArcGIS recommends not using a number to start a column name (from ESRI):

"For ArcGIS to work with multiple data types, certain characters in field or table names are not supported. These characters include spaces, hyphens, such as in the term 'x-coord', brackets, and other special characters. These limits are imposed so that ArcGIS is able to function with the maximum amount of data types.

  • Eliminate any characters that are not alphanumeric character or an underscore.
  • Do not start field or table names with an underscore or a number.
  • It is necessary to edit the field names in delimited text files to remove unsupported characters before using them."
| improve this answer | |

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.