Load .dbf File into QGIS – Shapefile Loading Guide

qgisshapefile

I want to use QGIS to extract lat/lng data from the vertices of polygons. There are about 400 polygons, each with maybe 200 vertices. I am having trouble with step one, getting the data into QGIS.

The polygons are viewable in ArcGIS Explorer using a zip file that contains files with the following extenstions:

.shp, .dbf, .sbn, .sbx, and .prj

I can load the .shp file into QGIS, but without the other files there is nothing to view. How do I load the .dbf, .sbn, .sbx and .prj files into QGIS?

Best Answer

The set of files that you have is referred to collectively, as a Shapefile. It is a common spatial data format developed by ESRI that is used for data transfer between many different packages.

This format consists of 3 primary files with the same name, but the following file extensions:

  • .shp
  • .dbf
  • .shx

A file containing Projection information:

  • .prj

Plus a couple of files generated by software that are spatial indexes:

  • .sbn
  • .sbx

Of the first 3 files, the .shp file contains the spatial information, namely, x,y coordinate pairs describing the point, line or polygon features contained in the file.

The .dbf file is a dbase format file, and contains the Attribute information, or the descriptive characteristics of the features. Some examples of this would be: "Name", if the feature is a point representing a city; "Road Name", or "Speed", if the feature is a line representing a street; or "Population" if the feature is a polygon representing a county area*, or country.

The .shx file acts as a linking file between the .shp and .dbf. It matches up the correct row in the .shp file with the correct record in the .dbf file.

Without these first 3 files, you do not have a valid shapefile.

The other files listed are optional, though the .prj is necessary for correct positioning of your data with respect to other spatial data, and for measuring and calculating distance. See Map Projection, for more information.
The .sbx and .sbn are generally created automatically when the shapefile is created. They can, however, be deleted and recreated without invalidating the shapefile as a whole.

Generally, when you use software that is able to read this format, the files listed in the add layers window are the .shp file. The other files are automatically loaded in. If, however, there is a problem with one of the 3 primary files, the .shp file may be loaded in, but an error will appear saying that this is not a valid shapefile, or simply no features will appear.

In the case you have shown, you appear to be missing the critical .shx file. Without this, there is no connection between the spatial features and the attribute data, thus the software is not able to load the shapefile in properly. What you need to do is go back to the source of your data and make sure that you obtain the .shx file as well. Once you do that, you should be able to load the data in with no problems.

This answer may be overkill, but it helps to know what the files included in a shapefile are for. It may help in the future to know what to look for if you encounter a similar problem.