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.

Why won't it open the shapefile for the conversion?

  • 3
    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
  • 2
    Does the index file exist? – Ian Turton Nov 9 '11 at 21:21
  • 3
    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: WATER_AREAS.shp.GEOMAP.168.4344.sr.lock. What does that mean? – nix Nov 9 '11 at 21:27
  • 2
    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

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 http://en.wikipedia.org/wiki/Shapefile for further information. That would explain the error message.


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.

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.