5

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?

enter image description here

  • 2
    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
  • 2
    @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
  • 1
    @HichamZouarhi - Ahh, I barely see questions involving both ArcGIS and PostGIS together :) – Joseph Jun 28 '16 at 13:38
  • 1
    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 at 7:51
2

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

enter image description here

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

enter image description here

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

1

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

1

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.

0

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

0

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.

-1

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;

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.