Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when import shapefile on postgis with shp2pgsql (unable to open shapefile)?

I use postgresql 9.1, postgis 2.0.1. For importing the shapefiles to my database, I use shp2pgsql. I have tried many ways for importing theses shapefiles (shp2pgsql -I roads.shp public.roads | psql -d map), but the result is always:

Unable to open roads.shp or roads.SHP.
roads: dbf file (.dbf) can not be opened.

How do I solve this problem?

like image 385
allicius Avatar asked Dec 20 '22 13:12

allicius


1 Answers

A "shapefile" is actually more than one file (i.e., more than just a .shp file). Make sure all of the files are in the same folder when using with any GIS software, including shp2pgsql.

The minimum required files, sharing a common prefix, are:

  • .shp — geometry data
  • .dbf — attribute data
  • .shx — geometry index file

Other files may include: .prj, .sbn, .sbx, .fbn, .fbx, .ain, .aih, .ixs, .mxs, .atx, .shp.xml, and .cpg.

like image 89
Mike T Avatar answered May 12 '23 22:05

Mike T