• Blog posts

    Bio

    By David Crowther

    QGIS___Rename_Fields_-_1.PNG

    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.

    QGIS___Rename_Fields_-_2.PNG

    Because there is no option to rename the field, we can use the Field Calculator tool to add a new fieldCounty – and then use the update option to update that new field with the values in the existing field called – FILE_NAME.

    QGIS___Rename_Fields_-_3.PNG

    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___Rename_Fields_-_4.PNG

    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.

    QGIS___Rename_Fields_-_5.PNG

    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.

    QGIS___Rename_Fields_-_6.PNG

    Choose the Rename Field menu option and complete the window below.

    QGIS___Rename_Fields_-_7.PNG

    • 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).

    QGIS___Rename_Fields_-_8.PNG

    If you view the Attribute Table, you can see that the original field named FILE_NAME has now been renamed to be called COUNTY.

    QGIS___Rename_Fields_-_9.PNG