0

enter image description here

I'm using QGIS and trying to remove the "ACS block group" prefix from each field in this attribute table. When I try to rename my attribute columns it says "Failed to rename field to ...Is this field unique?"

It is a unique field, so what else might be happening?

enter image description here

enter image description here

2
  • 2
    what is the data source? could this maybe be a reserved name? does it work when renaming it to another name? or without capital letters?
    – Dror Bogin
    Dec 12 '20 at 15:32
  • It won't let me change the field to any name; I tried a few. I think it may have to do with the fact that these field names are the result of a join. Here is the data I'm using: gisdata.mn.gov/dataset/us-mn-state-metc-society-census-acs
    – DanG
    Dec 12 '20 at 17:21
4

You are trying to rename a field created by a table join. You can't rename a field there - go to the joins tab an make your changes there (for Custom field name prefix, if you have defined any) or in the original tables that you join. Then probably your join has to be created from the scratch, so be careful with renaming. At least the Target field and Join field will not work any more if you change them and you have to define them again.

According to your description, I guess the ACS block group is the prefix set in the joins tab - so that should be easy to change. But be aware: if you have any "links" to fieldnames in your project (like in virtual fields or virtual layers), they will not work any more if changing field names. So reflect what consequences renaming in your case will result and if renaming pays off.

You could also use field alias. See in the documentation for more information. There you also find some information about the fact that depending on datatype, some options are restricted. If using shpefiles, your fieldnames can contain max. 10 characters.

For regular (not joined) fields remains valid what I stated in my first answer: The error message means that you already have a field with the same name. So somewhere in your quite long list there already exists a field named GEOG_UNIT. If you change the name to a string that does not yet exist as fieldname, it should work.

Fields should have unique names - otherwise you are not able to refer to them.

Be aware that not all kind of layers offer the possibility to rename fields - see thedocumentation linked above for details.

11
  • Thanks, can you tell me how to edit fields from the joins tab? I edited my post to include a screenshot of what it looks like, and I don't see any way to edit from there.
    – DanG
    Dec 12 '20 at 17:24
  • You can only change the prefix in the joins tab: in your screenshot, double click on join layer, in the opening dialog, at the bottom you can define the prefix, see: i.stack.imgur.com/7pAeL.png
    – Babel
    Dec 12 '20 at 17:51
  • Be careful what you change - when you already have "linked" your fields (like virtual fields or virtual layers), they will not work properly any more without setting them manually to the new values
    – Babel
    Dec 12 '20 at 17:53
  • I'm only renaming the fields because of the issue from the first screenshot that I had when exporting to a new shapefile. But, you're right, renaming the fields is causing more problems than leaving them. QGIS keeps crashing now, even after I erased the join and tried it again. But I don't understand the problem with the first error I got. If you have a long field value name are you not allowed to create a shapefile from it?
    – DanG
    Dec 12 '20 at 18:35
  • You can save it as a shapefile, but fieldnames will be cut to the first 10 characters. Try saving as Geopackage, it doesn't have this limitation
    – Babel
    Dec 12 '20 at 18:39

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.