7

I can find multiple tutorials that show how to import shapefiles to postgis via pgAdmin-3. But pgAdmin-3 is no longer supported.

How to do this with pgAdmin-4?

M--
  • 25,431
  • 8
  • 61
  • 93
Henrik K
  • 157
  • 1
  • 1
  • 6
  • Does this help? http://gis.stackexchange.com/questions/87019/loading-shapefiles-into-postgis-using-shapefile-import-export-manager – chrki Nov 19 '16 at 09:43

5 Answers5

13

Disclaimer: I know this isn't a valid answer, but I don't have the reputation to comment.

I'd strongly recommend QGIS for this. The import dialog that comes with the Database Manager is rather great. First load the shapefile into QGIS and add a new connection via the "Add PostGIS Layers" button (elephant icon) on the left > "New". Then go to Database > DB Manager > DB Manager, select the newly created connection and open the import dialog (down arrow icon).

If you're into command line tools try ogr2ogr (http://www.bostongis.com/PrinterFriendly.aspx?content_name=ogr_cheatsheet)

chris
  • 423
  • 2
  • 9
7

I just found this. It works perfectly:

"C:\Program Files\PostgreSQL\9.6\bin\postgisgui\shp2pgsql-gui.exe"

Henrik K
  • 157
  • 1
  • 1
  • 6
0

If you have a relatively simple shape, another approach is to use tools that can convert SHP to WKT (e.g. QGIS, or this website). WKT is the Well-known text representation of geometry used in PostGis and you can simply copy this text into an SQL Query in PGAdmin IV etc., for example:

SELECT *
FROM   public.geom_table
WHERE  column_latlng 
    @ -- contained by
    POLYGON((-6.6796875 39.111328125, -29.1796875 20.478515625, -32.6953125 -10.810546875, 12.65625 -24.873046875, 32.34375 1.142578125, 21.26953125 31.201171875, 17.75390625 38.759765625, -6.6796875 39.111328125))
Alex
  • 2,784
  • 2
  • 32
  • 46
0

Another option (for MacOS) is to download the Opengeo Suite 4.8 from here http://mac.softpedia.com/get/Developer-Tools/OpenGeo-Suite.shtml.

Then only pull the PostGIS Utilities to your applications folder. You can then delete the pgAdminIII App and just use the pgShapeLoader. Works with pgAdmin4 too.
After that, follow the instructions from this Boundless Tutorial:
http://workshops.boundlessgeo.com/postgis-intro/loading_data.html

I don't know if or how this is working for Windows.
I am running postgres 10.4 with pgAdmin4 on MacOS 10.13.

blabbath
  • 442
  • 7
  • 27
-1

You can easily import and export shapefile using build in PostGIS tool "PostGIS shapefile and DBF loader exporter" or you can use command prompt to load it. the related video for import and export shapefile is here:

https://www.youtube.com/watch?v=cgl6-FmpOVo #cmd to load shapefile https://www.youtube.com/watch?v=1L7QGFlAZq4 #load directly from build in PostGIS tool

Tek Kshetri
  • 2,129
  • 1
  • 17
  • 41
  • The extension/GUI mentioned in the video come up with pgadmin3 only, You probably would have installed pgadmin3 before. The question is how to do this with padmin4 – muzaffar Jun 08 '19 at 07:51
  • 1
    You have to install postgres 11.3 package from : https://www.enterprisedb.com/downloads/postgres-postgresql-downloads watch installation guide: https://www.youtube.com/watch?v=-V-54wGjebs&list=PLyWyQBSWLw1NPObUUhIDx50LWd88lZfpJ&index=1. The required GUI is come up with this installation. – Tek Kshetri Jun 11 '19 at 15:41
  • 1
    This is borderline spam – Nitrodist Feb 07 '20 at 21:16