# PostgreSQL Shapefile import failed

I am very new to PostGIS/PostgreSQL. In fact, I downloaded it because of the answers I got to this question: Distance between centroid and farthest point of polygon

I installed both PostgreSQL and PostGIS. But I am not able to import a shapefile to the database? It gives an error, "Shapefile import failed". What am I doing wrong?

• Probably doesn't like that your shapefile is a multipolygon. You could try using Vector > Geometries Tools > Multipart to Singleparts from the QGIS menubar and see if you can import again. – Joseph Jun 28 '16 at 9:24
• @Joseph I think she is using ArcGIS not QGIS, there is a similar tool in ArcGIS too – Hicham Zouarhi Jun 28 '16 at 13:34
• @HichamZouarhi - Ahh, I barely see questions involving both ArcGIS and PostGIS together :) – Joseph Jun 28 '16 at 13:38
• I've received this error before when trying to import a file that is also open in QGIS. It produces the same error (at least on my machine). After closing QGIS (or alternatively using a copy of the shapefile) I could import the shapefile without issue. I'm not sure if similar behavior occurs with ArcGIS (or machine-specific) but worth a shot for anyone who has tried everything else. – Don P Aug 31 '17 at 20:40
• So how did you remove this 'geom' field which is the default default geometry field name of Shp2pgsql GUI? What I did not happen. Can you help? – Mücahit Yılmaz Oct 6 '19 at 7:51

you have to install postgis extension on database "create extension postgis"

First chek if you had already installed the Postgis Extension, if not the Import will be failed , because this extension is responsable to talk with postgis-shape-Loader

if didn't insatll it then :write a query in the "your database": Create extension postgis;

The problem is maybe with the type of your geometry as you see its type is Polygon Z in ArcGIS but you are trying to convert it as polygon to use it in PostGIS.

I did some search and found this workaround:

run Feature Class to Feature Class tool then (before executing it) in 'Environments' at the bottom > expand Z values > set 'Output has Z Values' to Disabled

there are some issues like this one in the esri web page if you want to consult it

I have encountered a similar problem and searched to find only this post relevant, although my polygons are simply two dimensional. Here is my import configuration.

Importing with configuration: sz_div_st_cell, public, geom, F:\path\to_polygons.shp, mode=c, dump=1, simple=0, geography=0, index=1, shape=1, srid=0

Shapefile type: Polygon

PostGIS type: MULTIPOLYGON[2]

Shapefile import failed.

After checking the input shapefile several times, I found that the polygon shapefile itself, which came from an postgresql export and underwent some operations in ArcGIS, had a field named 'geom' in its attribute table (.dbf), and caused the import failure. After removing that 'geom' field, which was the default geometry field name in shp2pgsql GUI, the import went smoothly and successfully.

in my case, specifying a database in connexion details solved the error message :)

Simple solution: from the "SRID" in the PostGIS, Check the EPSG value from QGIS and paste it in the SRID then your problem is solved.

I confirm that in most cases it is a column in your data called "geom" which duplicates with "geometry". It must be deleted (geom) before import. From QGIS for example by going to the DB manager by connecting directly to your Database at best and by making an SQL query excluding this field.

If it's not resolved yet. I think it's a PostGIS extension you need to load.

With PostGIS extension execute this query: create extension postgis;