Monday 29 January 2018

postgis - Error importing shapefile into postgreSQL using shp2psql?



I've tried this a few different ways and keep getting the same error. I have a shapefile currently in WGS84 UTM Zone 15 which is SRID 32615.


I used the ArcMap multipart to singlepart tool to create a singlepart polygon. I followed the instructions found at http://postgis.net/windows_downloads to install postgresql and postgis.


I open pgAdmin III and select the postgis_21_sample table. Plugins > PostGIS Shapefile and DBF Loader 21.


I check connection details and it connects fine. I add my .shp file. I set Schema to public and Table to postgis_21_sample. I leave geo column alone and set SRID to 3265.


When I click import I get


==============================
Importing with configuration: postgis_21_sample, public, geom, C:\GIS\forest_buffer\postgres_single.shp, mode=c, dump=1, simple=0, geography=0, index=1, shape=1, srid=3265
Shapefile type: Polygon
PostGIS type: MULTIPOLYGON[2]
Failed SQL begins: "SET CLIENT_ENCODING TO UTF8;

SET STANDARD_CONFORMING_STRINGS TO ON;
BEGIN;
CREATE TABLE "public"."postgis_21_sample" (gid serial,
"shape_leng" numeric,
"shape_area" numeric,
"orig_fid" int4);
ALTER TABLE "public"."postgis_21_sample" ADD PRIMARY KEY (gid);"
Failed in pgui_exec(): ERROR: function addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does not exist
LINE 9: SELECT AddGeometryColumn('public','postgis_21_sample','geom'...
^

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Shapefile import failed.

I've also tried projecting this shapefile to WGS84 with SRID 4326 and receive the same error.


There are >100,000 features and I need to buffer, dissolve, negative buffer, and finally buffer back to the original size to fill gaps. ArcMap and QGIS fail to do it after days of waiting.



Answer



Are you sure you checked whole instruction including creation of new database and spatialy enabled it? You can't import to any of templates, so you have to create new database, connect to it and before import you have to execute query:


CREATE EXTENSION postgis;

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...