Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

The shapefile specification (http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf) only says "Record numbers begin at 1." (page 5), which doesn't specify what the field actually is. As per page 25, each shape feature must correlate to exactly 1 record in the DBF, and their order must be identical. So the "Record Number" field is not for any purpose related to the DBF. My interpretation is that the "Record Number" field is required to count up from 1 to the number of shape features in the shape file. But this being completely redundant, I am unsure whether I missed something?

Some clarifications after reading your answers and comments:

  1. I am writing a reader/writer for shapefiles, so I need to parse them correctly as well as produce valid output.
  2. Shapefiles as well as DBF files have an "intrinsic" record number (let's call them A and B). The first shape / record after the header in the shapefile / DBF has A=1 / B=1, the next has A=2 / B=2, and so on. The shapefile specification clearly states that the shapes and records have a one-to-one relationship based on these numbers, so the attributes for shape A=1 are contained in record B=1, and so on. Neither A nor B is the "Record Number" field I am asking about.
  3. Each shape in the shapefile also has an (explicit) INT32 field in its shape header, which is called "Record Number" in the shapefile specification. This is where my confusion starts. Let's call this value C. The specification requires that this field starts at 1 (so for shape A=1, it must be C=1). But it doesn't give any other rules (such as "increment C by 1 for each shape"), nor does it give any semantic meaning to this field. So it seems to me that C is indeed meaningless. But if that is true, the shapefile is bloated by 4 unneeded bytes for each shape, which seems weird to me. So I want to be sure I am not missing anything...
  4. I have no idea where things like "FID, OID, OBJID, or OBJECTID" come from. I am not using any ESRI products, but glancing at http://support.esri.com/es/knowledgebase/techarticles/detail/37480 I conclude that those are properties / attributes some ESRI products use and store in the DBF file associated with the shapefile. If that is so, this has nothing to do with my question.
share|improve this question
1  
Check out support.esri.com/es/knowledgebase/techarticles/detail/37480. From that is this statement: In a shapefile, the 'FID' field contains the ObjectID, and the values start at zero –  johns Mar 27 '13 at 14:33
1  
You don't indicate why the question is interesting to you, but if it's in a programming or reverse engineering context studying the Shapefile C library (Shapelib) is likely time well spent. –  matt wilkie Mar 27 '13 at 16:11
add comment

3 Answers

It should be something like FID, OID, OBJID, or OBJECTID.

It is the unique identifier for that table which maps the geometry to the attributes.

share|improve this answer
add comment

I believe that there is a relationship. From our (Safe Software's) Readers and Writers Manual:

An Esri shapefile consists of a main file, an index file, and a dBASE table. The main file is a direct access, variable-record-length file in which each record describes a shape with a list of its vertices. In the index file, each record contains the offset of the corresponding main file record from the beginning of the main file. The dBASE table contains feature attributes with one record per feature. The one-to-one relationship between geometry and attributes is based on record number. Attribute records in the dBASE file must be in the same order as records in the main file.

So, according to my info, there is a 1:1 relationship between Shape and DBF via the record number.

share|improve this answer
    
This sentence is incorrect, "The one-to-one relationship between geometry and attributes is based on record number" The relationship cannot be based on record number because the .dbf has no record number. The relationship is purely by position. The first shp record, whether is has a record number of 0 or 1 is related to the first dbf record. –  klewis Mar 28 '13 at 2:43
1  
@klewis You might be a little too severe here. DBase files do have implicit record numbers by virtue of their fixed record length. A DBase file begins with a pre-header that includes information about total length of the (physical) file and a header from which the record length and structure can be read. This allows random access to the table records (as it was originally intended to do). The .shx file exploits this by associating these physical record numbers to each shape. (Going in the other direction would require a table of shape offsets, because shapes have variable lengths.) –  whuber Mar 28 '13 at 3:43
add comment

There is a 1 to 1 correlation to the record in the .shp file and the .dbf. However, this is based on the record order in both the .shp and the .dbf. There is no connection based on any field/value stored in the .dbf. If you open the .dbf in something other than ArcGIS and perform a sort on any field and then save the .dbf file, you can mess up this referencing. The shape file will continue to work but the attributes may no longer be applied to the proper shape.

I found this out the hard way years ago when I was looking for a better way to manage the attribute data with out the overhead of ArcView 3.X

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.