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?
10 Answers 10
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.
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.
You can use QGIS, and drag the map to the db.
-
How? Could you give more information?Kadir Şahbaz– Kadir Şahbaz2020年09月21日 13:44:23 +00:00Commented Sep 21, 2020 at 13:44
"create extension postgis" worked when I added it in the psql command prompt, but didn't work when I entered it into pgAdmin.
-
2Is this an answer to the question or a new question?Kadir Şahbaz– Kadir Şahbaz2020年11月10日 01:10:01 +00:00Commented Nov 10, 2020 at 1:10
In my case, specifying a database in connection details solved the error message.
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.
I found that a symbol character (2) in a field heading was not recognised by PostGIS and prevented import, once removed problem solved.
It might be a different issue.
Once in my specific case it was (that I saw from others here but with some differences) - that it is based on wrong connection settings. PostGIS accepts the connection settings, even if you don't have a "Database", or if you have a wrong Server Host.
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;
Vector > Geometries Tools > Multipart to Singleparts
from the QGIS menubar and see if you can import again.