6

The .shp, .dbf and the rest of files are fine, I open them in QGIS, AGOL with no problem. In fact, I've tried 3 different layers, and get always the same error.

Anyone can please help, as I really need to migrate my .shp's to postgis, and have no idea of why it's not able to open .dbf?

Postgres v9.3 x86 Postgis shapefile loader v2.1

Thanks a lot in advance!

PS I've tried changing the default character encoding from the default 'UTF-8' to 'ISO 8859-14' but same error.

6
  • Have you tried the shp2pgsql-gui tool? Commented Oct 18, 2013 at 15:20
  • And are you trying to import just a .DBF, or an entire shapefile including .DBF? Commented Oct 18, 2013 at 15:20
  • Do you close your layers in QGIS or maybe OpenOffice if you opened the DBF like that? Sometimes, problems only comes from a lock between programs
    – ThomasG77
    Commented Oct 18, 2013 at 17:34
  • could be permissions issues on your .dbf files Commented Oct 18, 2013 at 18:57
  • Without seeing the files themselves, there's no way to debug or replicate this. Commented Oct 20, 2013 at 17:43

6 Answers 6

11

I just faced the same problem. I solved it by changing the location of shapefile. It seemed a problem of too long file name. When I moved the files up in folder tree, it worked perfectly, using the plugin.

2
  • this seems to be the good one, worked fine for me aswell, thanks a lot Sergio!
    – Guillermo
    Commented Oct 17, 2014 at 12:11
  • Also had this problem with PostGIS 2.4.2 and filename probably too long or with special characters (accented letters).
    – kogexo
    Commented Jan 25, 2018 at 11:47
2

Please check out http://www.gdal.org/ogr/drv_pg.html GDAL OGR2OGR to load shapefile data into postgis

Ogr2ogr Command to import shape into postgis

ogr2ogr -f "PostgreSQL" PG:"host=myhost user=username dbname=mydbname password=mypassword" your_shapefile.shp

For details http://www.bostongis.com/PrinterFriendly.aspx?content_name=ogr_cheatsheet

2
  • Thanks a lot Farhat, what finally seems to have worked (further checking pending) is importing geodatabase files into postgres using OGR2OGR. Great tools, thanks a lot again!
    – Guillermo
    Commented Oct 22, 2013 at 9:33
  • 1
    That link doesn't work anymore. Commented Oct 20, 2017 at 15:21
2

I've had the same error. In my case the solution is also the path name. The path name must not have any special characters like ä,ö or ü.

1

In PostGIS 2.4 I ran into this because I tried passed DB credentials following earlier versions -- you must pipe to psql instead now, e.g.:

shp2pgsql shaperoads.shp myschema.roadstable | psql -d roadsdb

In short, this error often shows up for unrelated problems (any kind of bad input or options).

0

DBF files can be opened by the dint of foxpro dbf recovery software

More info about this solution on oemailrecovery.com.

0

In my case the folder name had a Latin character like ã ê ç. I just renamed it and worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.