6

I am having a problem opening a shapefile using QGIS using 'add vector later'. This is the error message I am getting:

/Users/Conrad/AmerindianLands 2/Amerindian_Land_Karasabai.shp is not a valid or recognized data source

Can anyone help?

I have made sure that it is being extracted from a folder containing the other necessary files with the following extensions (.dbf,.prj,.shp, .sbx,.sbn).

nmtoken
  • 13,355
  • 5
  • 38
  • 87
Conrad Feather
  • 61
  • 1
  • 1
  • 2

2 Answers2

7

Have you got the *.shx file? It seems to be required to open shapefile.

Dan C
  • 12,212
  • 11
  • 57
  • 86
dmh126
  • 6,732
  • 2
  • 21
  • 36
  • 1
    I do not have an .shx file and suspected this might be a problem - I changed the .sbx file to an .shx file thinking it might help and it loads up but nothing appears? – Conrad Feather Apr 01 '14 at 15:05
  • 3
    That's your problem. Only 3 of the shapefile's individual files are actually necessary for it to work: the .SHP, .SHX, and .DBF files. If one of those is missing, it won't work. – Dan C Apr 01 '14 at 15:21
  • 1
    I think there is a huge difference between this two files, so you cant simple change sbx to shx. – dmh126 Apr 01 '14 at 15:26
  • You can generate a new .shx by reading the .shp and generating the required records, but you can't throw random binary data into a .shx and expect it to work. – Vince Apr 01 '14 at 15:53
  • 1
    @Vince there is no guarantee the records in the .shp file will correspond correctly to the records in the .dbf file. Often they will, but if the shapefile has undergone extensive edits and deletions--and depending on the software used to do them--there is no way reliably to recover the correspondence. – whuber Apr 01 '14 at 16:06
  • @whuber It is the absolute responsibility of applications which write shapefiles to preserve the 1:1 correspondence between .shp records and .dbf records. The .shx has no role except to provide pseudo-direct access to .shp record starting points. – Vince Apr 01 '14 at 16:19
  • 2
    @Vince That is not the case according to the ESRI technical description that governs the shapefile standard. I refer you to page 2 (which gives an overview) and page 23 (describing the .shx file). Nowhere does this document guarantee what you say. In fact, such a guarantee would obviate any need for the .shx file at all. Plenty of people have discovered this fact when they attempted to recreate a missing or corrupted .shx file and found that the attributes were mis-matched to the features. – whuber Apr 01 '14 at 16:24
  • Quoting page 2: 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. – Vince Apr 01 '14 at 16:27
  • The difficulty in recreating .shx is due to gaps in the .shp, which is a different issue, and has no relationship to the dBase file. – Vince Apr 01 '14 at 16:29
  • @Vince - Unfortunately, even if you are able to recreate an .shx file that is correct regarding record numbers, the data may still be corrupted. This is because the components of a shapefile are editable by more than just software which treats them as a whole. The .dbf may be edited in Excel. Any sorts that are performed and then saved will change the records associated with a particular record number. So, while it may be possible to recreate an .shx file and gain access to a shapefile in some software, it is no guarantee of the integrity of the data. – Get Spatial Apr 01 '14 at 18:20
  • I never said that recreating the .shx would fix dBase corruption, though I did say that the .shx has no relationship to the .dbf. A missing file does not automatically mean the dBase file has been corrupted, and even if all three files are present, they could have been corrupted by ASCII ftp transmission. .shx recovery should only be a last gasp effort before admitting the shapefile content has been lost. – Vince Apr 01 '14 at 18:36
  • 1
    Ok many thanks to you all for your comments, as a beginner GIS user the discussion is a bit over my head but my conclusion is that I need to go back to the person who sent the file to me and ask them if they have an .shx file...otherwise it won't work. Is that a fair conclusion? – Conrad Feather Apr 02 '14 at 08:43
0

LAYERS -> ADD LAYER -> ADD VECTOR LAYER

Select the shp file in VECTOR DATASETs.

Import.

When it didn't work for me withe the same files I was using the wrong menu item or selecting the wrong files.

twobob
  • 101
  • 2