3

Shapefiles (vector layers) has FID or OID fields associated with each row (feature). This information is readily available in the attribute table viewed in Arcmap. However, QGIS Desktop does not seem show the FID field. Does anyone know how to view FID field in QGIS Desktop?

  • 2
    The FID or OID fields are completely arbitrary fields that are only used to organize features internally for display on the map in both QGIS and ArcMap. They should not be used to assign ID's to features nor should they be used in JOINS or RELATES of any kind. What are you trying to do with these fields? – DPSSpatial Oct 3 '16 at 19:06
  • 1
    I understand that. Still I was perplexed that QGIS does not even show this field. Because I do not have unique fields in my shapefile, I use the FID to select specific features (say lines). Right now I am just trying to find out if it is possible to see the FID field or not. – bny Oct 3 '16 at 21:38
  • 1
    The FID field displayed by ArcGIS does not exist. It is an artifact of ArcObjects implementation. In fact, if you create a "FID" column in a dBase table, ArcGIS will rename it. – Vince Oct 3 '16 at 23:53
  • @bny you should create an ID field relevant to your data, even if it begins with a 1,2,3 ROWNUM function to get you started... never rely on a field called FID, OID, or really ID to give your features unique identifiers. If QGIS doesn't display it, I trust this is the reason why... – DPSSpatial Oct 4 '16 at 0:04
5

Yes. Agree with the answer from DPSSpatial. FID is the unique identifier of an object within a table. Between, the ways to get FID in QGIS:

  • In the field calculator, create a new column, named "Fid".
  • With expression: @row_number - 1 (ArcMap's FID is starting with 0. But, @row_number is starting with 1).
  • 3
    Note that an additional FID column could be added as a virtual column, meaning you don't need to modify the original shapefile. Also $id is the variable that refers to the FID (starts at zero). – jpmc26 Nov 28 '16 at 22:14
2

What are you trying to do with these fields?

The FID or OID fields are completely arbitrary fields that are only used to organize features internally for display on the map in both QGIS and ArcMap. They should not be used to assign ID's to features nor should they be used in JOINS or RELATES of any kind.

You should create an ID field which is named relevant to your data, even if it begins with a 1,2,3 ROWNUM function to get you started... never rely on a field called FID, OID, or really ID to give your features unique identifiers. If QGIS doesn't display it, I trust this is the reason wh

  • Adding additional field to the shapefile is computationally prohibitive for me, because I am working with National Hydrography Database (NHD) spanning all across USA. I do not use FID for any additional processing. I use it just to select some stream features for deriving and visualizing the longitudinal stream profile. So even if FID/OID are arbitrary fields, I do not per se use the FID for any geo-processing. From most your comments it seems that FID field cannot be viewed in QGIS. Actually that was my original question - How to see FID attribute in QGIS software. – bny Oct 5 '16 at 22:09
1

Actually, FID is not an official shapefile term, but refers to the row number in the unsorted table. Since Esri originated the format, calling this an artifact of arcgis is rather strange. Being a row-number, it is not stored in a column of the attribute table (DBF). The row number is used to tie the row to a specific shape. FID can be seen in QGis when identifying a shape under Derived->Feature ID. Further, there is a field in the SHP specification called Record Number at byte 0 of the record header(s), 1 based. But: "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, there's a bit of ambiguity about record number here and I, for one, do not count on the SHP Record Number to be properly maintained. So, the idea of sorting/ordering by FID is to use the unsorted order, i.e. in original stored order. There is nothing arbitrary about that, and I wish, more generally speaking, that this sort of downtalking like "arbitrary artifact" is more often seen as a style potentially hiding ignorance or lack of interest. My reason to find this exchange is an attempt to unsort a feature set after sorting it on an attribute column. Sorting on @row_number did NOT restore the original order, sorting on $id, however, did. For my purposes, the comment of jpmc26 is the best answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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