Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to import a shapefile to Postgres using the following:

shp2pgsql c:\location\water_areas.shp water > water.sql

I am receiving the following message:

c:\location\water_areas.shp: shape (.shp) or index file (.shx) can not be opened, will just import attribute data.

Unfortunately I need more than just attribute data. I need the geometry column. Please help. Why won't it open the shapefile for the conversion.

share|improve this question
have you looked in c:\location and checked that water_areas.shx and water_areas.shp are there? – Stev_k Nov 9 '11 at 21:20
Does the index file exist? – iant Nov 9 '11 at 21:21
Let's ask the dumb questions up front, just in case they suggest a quick easy solution: (1) do you actually have a .shp file in the same folder with the .dbf file, or is only the .dbf file present? In the latter case, you don't have the geometry data. (2) Do you have the .shx file in the folder, too? If not, you have geometry and attributes but you have lost the connections between them. (3) Is it possible that the shapefile might already by open in some other software which is holding a lock on it? – whuber Nov 9 '11 at 21:21
The .shp file is in the same folder as the .dbf file. There is no .shx file though. There is a .sbx file. I think it's possible that the file is locked...I found this file in the folder too: What does that mean? – nix Nov 9 '11 at 21:27
sbx is an index file. You definitely need to have the .shx file, so ask whoever gave you the files to include it – Stev_k Nov 9 '11 at 21:32
up vote 4 down vote accepted

Based on what you've told us, I would say that you need to find the .shx file to go with the .shp file and .dbf file. This is a mandatory component of any shapefile - see for further information. That would explain the error message.

share|improve this answer
Thanks. I have obtained the relevant .shx files and now the import works perfectly! – nix Nov 10 '11 at 15:09

the lock file either indicates that someone else has the file open (or the sender set it from within arcmap while HE had it open).
You do need the shx though. or you could do a repair.

shapechk.exe is what I use.
It will rebuild the shx. This is the index file between the shp and the dbf.

share|improve this answer

Your Answer


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.