By David Crowther
Question:
How can I rename fields in my GIS data using QGIS?
Answer:
Are you using QGIS but you still like using ESRI Shapefiles to store your GIS data?
That’s not a problem – but you will still be restricted by the age-old issues with the Shapefile format:
- Only allows one type of Geometry.
- Can’t have field names longer than 10 characters (due to DBF format).
- Can’t rename or reorder your fields.
Remember – storing your spatial data in other formats e.g. GeoPackage and Spatial Databases (e.g. SQL, PostGIS etc…) will help you overcome those issues.
… but back to our ESRI Shapefile…. is it possible to rename a field?
I know if I have had to do this with my Shapefiles, I have historically used a work around to achieve this:
- Create a New field with the required Field Name.
- Use the Field Calculator to then update that new field with the values from the original field (the one that has the incorrect field name).
Here is a Shapefile of the UK Counties, with the County Name value stored in the FILE_NAME field.
Because there is no option to rename the field, we can use the Field Calculator tool to add a new field – County – and then use the update option to update that new field with the values in the existing field called – FILE_NAME.
The output will be the new field called COUNTY with the values you need. However, it has been added at the end of the table, which you may not like!
QGIS – does have an Organise Table Columns tool that will also allow us to re-order the new field to be at the start of the table structure.
But this change is only temporary within that QGIS session.
Instead of using this work around, why not use the Rename Tool in QGIS.
In QGIS choose Processing > Toolbox > and open the Vector Table section.
Choose the Rename Field menu option and complete the window below.
- Input layer– choose the COUNTY Shapefile.
- Field to rename – choose the FILE_NAME field.
- New Field Name – type the new field name e.g., COUNTY.
Press Run and the tool will then rename the chosen field.
The output will be a copy of the original Shapefile now called Renamed and saved as a Temporary Scratch Layer – which can then be exported and saved as a GIS file (e.g., Shapefile or GeoPackage).
If you view the Attribute Table, you can see that the original field named FILE_NAME has now been renamed to be called COUNTY.
Comments
0 comments
Please sign in to leave a comment.