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.

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
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? –  iant 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
add comment

2 Answers 2

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 http://en.wikipedia.org/wiki/Shapefile 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
add comment

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
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.