By David Crowther
Question:
How can I change the table structure of 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.
Back to our ESRI Shapefile…. is it possible to rename, re-order and change the type of a field?
Yes –in QGIS choose Processing > Toolbox > and open the Vector Table section.
Choose the Refractor Fields menu option.
Choose the Input layer to be the layer/table that you wish to change, in this example we will modify the structure of the Counties layer.
The Refractor tool allows you to do the following:
- Rename a Field.
- Change the Field Type.
- Edit the Field Length & Precision.
- Re-order Fields.
- Add & Delete Fields.
Use a Field Calculator to build a new field (or update an existing field) using an expression. For example, creating a Crime Rate field, by dividing the Number of Thefts by the Population and then multiplying by 1000.
Make the required changes and press Run.
The output will be a copy of the original Shapefile now called Refractored 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 changes made using the Refractor tool have been implemented.
Comments (0 comments)